c# - How to write not equal operator in linq to sql? -


using (rapidworkflowdatacontext context = new rapidworkflowdatacontext())                     {                         var query = w in context.workflowinstances                         c in context.workflows                           empworkflowids.contains((int)w.id) && w.currentstateid != c.laststateid                          select w;                          return query.tolist();                     } 

i have 2 tables: workflows , workflowinstances.

workflows store objects , workflowinstances store instances.

workflows table: id,name,firststateid,laststateid

workflowinstances table: id,name,workflowid,currentstateid

how write query in linq sql select instances workflowinstances currentstateid not equal laststateid

you need revise join on related columns between 2 tables, add condition in clause, following:

using (rapidworkflowdatacontext context = new rapidworkflowdatacontext())                         {                             var query = w in context.workflowinstances                                         join c in context.workflows on w.workflowid equals c.id                                          empworkflowids.contains((int)w.id)                                          && w.currentstateid != c.laststateid                                          select w;                              return query.tolist();                         } 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -