c# - How can combine query in Entity Framework? -
i have implemented rest web service in c#. connect on database, have used entityframework.
i have code:
private iqueryable<clinicaldocumentdto> getclinicaldoc(string cf) { if (cf != null) { return p in db_data.clinical_doc p.codicefiscaleassisito == cf select new clinicaldocumentdto() //select new clinical_doc { code = p.code, codesystem = p.codesystem, datestart = ad.verifyeffectivetime, dateend = ad.verifyeffectivetimemax } } }
now want change code, have field "datestard" , "dateend", on database, have 3 column (effetivetime, effetivetimemin, effectivetimemax).
i want this:
if (effectivetime == null) datestart= effectivetimemin, dateend = effectivetimemax
how can in entity framework?
you can use ?:
operator in select mentioned below:
return p in db_data.clinical_doc p.codicefiscaleassisito == cf select new clinicaldocumentdto() //select new clinical_doc { code = p.code, codesystem = p.codesystem, datestart = p.effectivetime == null ? effectivetimemin : ad.verifyeffectivetime, dateend = p.effectivetime == null ? effectivetimemax: ad.verifyeffectivetimemax }
ps: casing of variables not checked. please updated them accordingly.
Comments
Post a Comment