public static TEntity FirstOrDefaultItem <TEntity>(this IQueryable <TEntity> source, Expression <Func <TEntity, bool> > predicate) where TEntity : class { if (source is IEntitySet <TEntity> ) { source = source as IEntitySet <TEntity>; } return(Expressions.FirstOrDefaultItem <TEntity>(source, predicate)); }