简体   繁体   中英

Query a SQL Server table with multiple variables using LINQ and C# and return the results

I want to search using multiple criteria and for every "discovery" to save to an object. I found a solution for multiple criteria here

But how can I save every find? The example uses a var and probably will only find one row but what happens when you have multiple rows that match your criteria and want to save them all? Should I use foreach ?

你需要这样的东西

myvariable.Where(x => x.id == list.id && (y => y.otherfield)).Select( x => x.somethingelse));

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