c# - Get total row count in Entity Framework -


i'm using entity framework total row count table. want row count, no clause or that. following query works, slow. took 7 seconds return count of 4475.

my guess here it's iterating through entire table, how ienumerable.count() extension method works.

is there way can total row count "quickly"? there better way?

    public int getlogcount()     {         using (var context = new my_db_entities(connection_string))         {             return context.logs.count();         }     } 

that way row count using entity framework. see faster performance on second+ queries there initialization cost first time run it. (and should generating select count() query here, not iterating through each row).

if interested in faster way raw row count in table, might want try using mini orm dapper or ormlite.

you should make sure table defined (at least, has primary key), failure can affect time count rows in table.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -