nhibernatelinq-to-nhibernate

The ExceptResultOperator result operator is not current supported


I want to exclude one resultset from another and I am using Except for that but it is giving error that "The ExceptResultOperator result operator is not current supported". I can not use all the conditions in where clause of a single query as it will give me unexcepted result.

//Sample code what I have tried

 var result1 = Session.Query<Table>()
                .Where(x => x.ColumnName != null && !x.active)
                .Select(x => x)

   var result2 = Session.Query<Table>()
                .Where(x => x.Active)
                .Except(result1)
                .Select(x => x)

Solution

  • You can use Contains instead of Except:

     var result1 = Session.Query<Table>()
                    .Where(x => x.ColumnName != null && !x.active)
                    .Select(x => x)
    
     var result2 = Session.Query<Table>()
                    .Where(x => x.Active && !result1.Contains(x))
                    .Select(x => x)