How to write not equal operator in linq to sql?

后端 未结 3 1426
using (RapidWorkflowDataContext context = new RapidWorkflowDataContext())
                    {
                        var query = from w in context.WorkflowInstanc         


        
相关标签:
3条回答
  • 2020-12-20 15:39

    You can eliminate join and it should be something like:

    var query = from w in context.WorkflowInstances
                where !context.Workflows.Any(c => w.CurrentStateID != c.LastStateID) && EmpWorkflowIDs.Contains((int)w.ID)
                select w;
    
    0 讨论(0)
  • 2020-12-20 15:52

    You need to revise the join to be on the related columns between the 2 tables, then you add your condition in the where clause, like the following:

    using (RapidWorkflowDataContext context = new RapidWorkflowDataContext())
                            {
                                var query = from w in context.WorkflowInstances
                                            join c in context.Workflows on w.WorkflowID equals c.ID
                                             where EmpWorkflowIDs.Contains((int)w.ID)
                                             && w.CurrentStateID != c.LastStateID
                                             select w;
    
                                return query.ToList();
                            }
    
    0 讨论(0)
  • 2020-12-20 15:55

    If you are using lambda expressions, then not(!) goes there:

    .Where(p => !p.Whatever...)
    
    0 讨论(0)
提交回复
热议问题