3- Entity Data Model LINQ-where & OfType

Data obtained with the filter operator has obtained about two methods, respectively, and where OfType.

1.where and data filtering

where the data filtering element for filtering operations is the object in the collection, according to the specified conditions return to meet this criteria is worth recording data, which is obtained by a common operation after obtaining data from clause.

Where the direct method using a more concise.

 

Since the issue involves the conversion after SQL statements, and therefore direct the where clause and then referenced independent function problems can not be resolved before further operation after the data must be fully loaded, you can choose to convert ToList, further reference where clause .

 

2.OfType- by type of screening a collection of objects

OfType method used to convert a collection of traditional support LINQ queries become IEnumerable object, it will skip the collection does not meet the specified type of object element, this method is very useful.

example:

 

Guess you like

Origin www.cnblogs.com/hcy-zyy/p/11125446.html