Dynamic LINQ DateTime Comparison String Building - Linq To Entities

前端 未结 5 1358
慢半拍i
慢半拍i 2020-12-19 04:54

I\'m using the dynamic LINQ library by Scott Guthrie together with Entity Framework and C#.

I have to build my where string into a variable based on several factors

5条回答
  •  北海茫月
    2020-12-19 05:53

    ObjectQuery.Where overload accepts 2 parameters.

    1. string predicate
    2. params ObjectParameter[] parameters

    In your first example, Where builds the query (where clause) using ObjectParameter parameters (using Name, Type and Value of ObjectParameter)

    In your second example, whatever is passed is treated as final where clause (no internal conversion based on datatype of passed parameters done).

提交回复
热议问题