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.
精彩评论