简体   繁体   中英

Bind a Datagrid to a Linq query in WinForms

I've been working in client-service applications all my life so now that I can do "wild things" like having the DAO in the client I think things can be better done 8-)

When I loaded a GridView in a client-server application I used to have a pagination...

If I make the call to the database from the client... may I bind the GridView to a linq query directly or should I call to a "ToList" or something like that before? I think GridView could make asynchronous calls to the query and make use of the lazy loading so I haven't got a 100.000 rows Grid...

Does this exist??? Is it possible??? Thanks in advance!!

You can still have pagination with Linq, you just have to properly use Skip and Take . Something like:

var bindResults = query.Skip(pageNumber).Take(pageSize);

This will execute and only give you the small subset of records you want to display.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM