LINQ filter | linq where in list
Language-integratedquery(LINQ)canhelpprogrammersretrievedatafrommultiplesourcesandshapetheirresultswithlesscoding.LINQfiltersdatatoavoidsearchingunnecessarydatasetsandtoreducetheamountofdatathatneedstobetransferredorhandled.Developerslikeitbecausetheydon’thavetolearnanewquerylanguageforeverytypeofdatasourceordataformat.Andit’stypesafe.ComparingvaluesUsually,analystsneedtocompareoneortwovaluesinadatabaseagainstalistofmany.Here’sanexample,usingmovielistings: Thegenrecolumnstoresvaluesasapipe-d...
Language-integrated query (LINQ) can help programmers retrieve data from multiple sources and shape their results with less coding.
LINQ filters data to avoid searching unnecessary data sets and to reduce the amount of data that needs to be transferred or handled. Developers like it because they don’t have to learn a new query language for every type of data source or data format. And it’s type safe.
Comparing valuesUsually, analysts need to compare one or two values in a database against a list of many. Here’s an example, using movie listings:
The genre column stores values as a pipe-delimited list of strings. The genres would typically be stored in a separate table, but this case also involved a M:M table, so it was easier to leverage the genre column instead of dealing with the joins.
You can search the movie listing for several genres by manually typing them or by selecting them from a CheckBoxList:
The selected genr...