开发者

Where in Linq using ObjectParameter

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜