Since IEnumerable.Contains () method does not accept a predicate as an argument Most people use it to see the existence of a condition with the following code:
// ProductId is unique if (product.count (c => c.productId = 1234) == 1) {// Product in the product list is 1234.} This code every product to run through the forces and to check it For whether it matches And there is no need to do so.
When viewing the SQL code generated by Linq-to-SQL, the same problem is Select Count (*) ... where the ProductId = @ p0 statement is sent, its Instead of if it exists .
How is this possible through Linq to find out if there is such a thing in any set that matches one condition, and matches through each element in the set To calculate the number of?
you
(if the product (someone Also (C = & gt; c.ProductId = 1234)) {// do stuff} Not sure if he exists, uses, but you can try And can see what has been sent.
Comments
Post a Comment