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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -