How can I call local method in Linq to Entities query?

后端 未结 4 1551
感动是毒
感动是毒 2020-12-10 14:51

I have the following code:

public void SalesCount(string customerId)
{
  ..
  ..
  return ...;
}

var resultQuery = dataContext.Customers
.Where (c => c.N         


        
4条回答
  •  一生所求
    2020-12-10 15:36

    yes, you can.

    but you should change return type for your function:

    public **int** SalesCount(string customerId)
    {
      ..
      ..
      return 500;
    }
    
    
    var resultQuery = dataContext.Customers.AsEnumerable()
                     .Where (c => c.Name == "Alugili" && SalesCount(c.CustomerId) < 100);
    

提交回复
热议问题