Structure of the object where the condition

I am new to EF how to use and - or to where where in an entity structure

HR_ATTENDANCE_DEVICE_SHUTDOWN_TBL attendanceDeviceShutdownTbl = 
    context.HR_ATTENDANCE_DEVICE_SHUTDOWN_TBL
        .FirstOrDefault(x => x.Device_ID.Equals(model.DeviceId) &&
                             x=>x.Device_Name=model.DeviceName);

the above code will not work, but how can I make it work.

+4
source share
1 answer

The lambda expression has the following syntax param => expression. That is, it is like a simple method that has an input parameter and a body. You define parameters only once, and then use them in the body of a method or lambda:

HR_ATTENDANCE_DEVICE_SHUTDOWN_TBL attendanceDeviceShutdownTbl = 
    context.HR_ATTENDANCE_DEVICE_SHUTDOWN_TBL.FirstOrDefault(x => 
        x.Device_ID.Equals(model.DeviceId) && x.Device_Name == model.DeviceName);

x, . - , () x.

x.Device_ID.Equals(model.DeviceId) && x.Device_Name == model.DeviceName

: - ( #). , == - . = - . .

+5

Source: https://habr.com/ru/post/1539757/


All Articles