c# - Linq to Entities figure out count of rows without returning rows -


i hope 1 of guys can me question: given method below, can cause count done on db server rather retrieve rows, , function should not running query each search name, should run 1 sql statement each call of function.enter image description here

you can simplify query dramatically using contains translated where in clause. count matching rows.

public static int countemployeesbyname(ienumerable<string> namestosearch) {     using (var context = new applicationentities())     {           return context.employees                         .where(e => namestosearch.contains(e.name))                         .count();     } } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -