Neubernath Chronology

public IEnumerable<UserReadNews> GetLatestUserReadNews(IEnumerable<string> userIds)
{

    IQuery query = Session.CreateQuery("from UserReadNews as j where j.FacebookUser_id in (:userIds)");
    query.SetParameterList("userIds", userIds );
    return query.List();
}

I have this method when I want to return this data as lazy as possible, because I determine which data should be shown and then stopped. I do not want the entire query to be executed with the entire table.

I'm worried about the List () method. is it lazy or impatient?

Is it possible to call this method from another method and yield breakwhen I finished what I need?

+3
source share
2 answers

I agree with @CSharper only to request what you absolutely need.

If you need to make it as lazy as possible after this optimization, use ICriteria.Future<T>()instead ICriteria.List<T>():

public IEnumerable<UserReadNews> GetLatestUserReadNews(IEnumerable<string> userIds)
{
    IQuery query = Session.CreateQuery("from UserReadNews as j where j.FacebookUser_id in (:userIds)");
    query.SetParameterList("userIds", userIds );
    return query.Future<UserReadNews>();
}

Future IEnumerable , . , .

+1

IQuery.List , .

( ) , , , .

+1

All Articles