i've got a really simple linq to entites statement :-
var query = (from q in Users.Include("UserHistory")
            select q).Take(20);
works great ... except that, for each use开发者_如何学Gor .. the history can be n+1. Some users have 100's of UserHistory records.
So, can I restrict the the number of UserHistory records to .. 10 or 5 or whatever?
Do I need to use projections for this? Can it be done without projections?
You can't do this by using the include, but you can try this:
var query =
    from user in Users
    select new
    {
        user, 
        history = user.UserHistory.Take(20) 
    };
I'm not sure whether EF is able to create one single SQL query of of it.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论