It's important to understand LINQ order in order to write correct LINQ statements.
Recently I bumped into this one:
public CRM_OPPORTUNITYCLOSED GetAcceptanceClosed(Guid guid)
return Context.CRM_OPPORTUNITYCLOSEDSet.FirstOrDefault(o => o.OPPORTUNITY_ID == guid.ToString());
When this was run to the Oracle DB, I got this error:
ORA-00932: inconsistente gegevenstypen: - verwacht, NCLOB gekregen
or in English:
ORA-00932: inconsistent datatypes: expected - got CLOB
So what happened? You would expect that the ToString() was called before EF would go the the DB? In this case NO. It passes the Guid value to the DB and you get the error above.
So do your to string convert before you use the query.
public CRM_OPPORTUNITYCLOSED GetAcceptanceClosed(string guid)
return Context.CRM_OPPORTUNITYCLOSEDSet.FirstOrDefault(o => o.OPPORTUNITY_ID == guid);