views:

491

answers:

2
A: 

It looks like you've got a soft delete model going on here, and you're trying to filter these out from being returned by the GetAll() method. I agree with your analysis that NHibernate.Linq doesn't properly process the typecast, but you may want to try replacing this with a query filter.

John Rayner
A: 
public virtual IQueryable<TEntity> GetAll()
{
  if (typeof(ILogicalDeletable).IsAssignableFrom(typeof(TEntity)))
  {
    return session.Linq<TEntity>().OfType<ILogicalDeletable>()
      .Where(x => !x.IsDeleted).Cast<TEntity>();
  }

  return session.Linq<TEntity>();
}

Try that.

Kim Johansson