I have this attempt to execute a query:
hmrSingle = dbMngr.Set<HistoryMessagesRequested>().Where(x => x.dateregistration == msgv.DtRicezione && x.val == msgv.value && x.parameter == dmf.Description && x.DeviceID == ms.IDDevice).FirstOrDefault();
dateregistration
and DtRicezione
are both declared as DateTime?
into the database context and they're "datetime" into MSSQL tables too.
I can't figure out why this problem is continuously present.
Any time you are using a nullable value type you need to use .value to get its value. Try:
hmrSingle = dbMngr.Set<HistoryMessagesRequested>().Where(x => x.dateregistration.value == msgv.DtRicezione.value && x.val == msgv.value && x.parameter == dmf.Description && x.DeviceID == ms.IDDevice).FirstOrDefault();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.