c# - Why IEnumerable<T> method call the database without condition? -


i have these method in generic repository :

public iqueryable<t> query() {     return _dbset.asqueryable(); }  public ienumerable<t> enum() {     return _dbset.asenumerable(); } 

if call these method in service layer

_repo.query().where(w => w.isactive == true); _repo.enum().where(w => w.isactive == true); 

the queryable method call tsql syntax in database, profiler below :

select      [extent1].[projectid] [projectid],      [extent1].[name] [name],      [extent1].[isactivity] [isactivity],      [extent1].[isactive] [isactive]     [dbo].[project] [extent1]     1 = [extent1].[isactive] 

which expected, enumerable method select in database without condition, profiler below :

select      [extent1].[projectid] [projectid],      [extent1].[name] [name],      [extent1].[isactivity] [isactivity],      [extent1].[isactive] [isactive]     [dbo].[project] [extent1] 

it means enumerable greedily call every record in database including isactive = 0 record. why happening? thought ienumerable suppose deffered means won't until tolist() called.

any appreciated , apologize bad english.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -