Passing func as parameter in Linq to Entities and 'Internal .NET Framework Data Provider error 1025' error

前端 未结 1 1556
面向向阳花
面向向阳花 2020-12-31 02:21

We have a class called Task:

public partial class Task : EntityObject
{
    public EntityCollection TaskUsers { get {...} set{...} } 
}
         


        
1条回答
  •  再見小時候
    2020-12-31 03:03

    Well the EF can only translate Expressions, not functions.

    i.e. it can translate this:

    Expression> 
    

    but not this:

    Func
    

    As for how to merge expressions (in pseudo code):

    Expression> expression = a => a.User.ID == 1;
    return tasks.Where(t => t.TaskUsers.Any(expression));
    

    There are probably some Expression guru's who can help with that.

    I suggest a followup question focused on that particular problem

    Alex

    0 讨论(0)
提交回复
热议问题