开发者

Where in Linq using ObjectParameter

开发者 https://www.devze.com 2023-02-22 21:48 出处:网络
I want to use ObjectParameter inside a LINQ query in the following way: var query = systemEntities.Clients.Where(\"it.age > @a\", new ObjectParameter(\"a\", 20));

I want to use ObjectParameter inside a LINQ query in the following way:

var query = systemEntities.Clients.Where("it.age > @a", new ObjectParameter("a", 20));

Then, I want to add another N where clauses to the same query like this:

var query = query.Where("it.age < @b", new ObjectParameter("b", 20));

Can i use the same ObjectParameter's name multipl开发者_运维技巧e times like this?

var query = systemEntities.Clients.Where("it.age > @a", new ObjectParameter("a", 20));

var query = query.Where("it.age < @a", new ObjectParameter("a", 20));


The answer to your question is no. From http://msdn.microsoft.com/en-us/library/bb896238.aspx

Parameters must be unique in the ObjectParameterCollection. There cannot be two parameters in the collection with the same name.

0

精彩评论

暂无评论...
验证码 换一张
取 消