【EFCORE笔记】元素操作&集合运算&转换类型

 

Enumerable.Zip

 

将指定函数应用于两个序列的对应元素,以生成结果序列。

 

Element Operations

Method Name

Description

More Information

ElementAt

Returns the element at a specified index in a collection.

Enumerable.ElementAt Queryable.ElementAt

ElementAtOrDefault

Returns the element at a specified index in a collection or a default value if the index is out of range.

Enumerable.ElementAtOrDefault Queryable.ElementAtOrDefault

First

Returns the first element of a collection, or the first element that satisfies a condition.

Enumerable.First Queryable.First

FirstOrDefault

Returns the first element of a collection, or the first element that satisfies a condition. Returns a default value if no such element exists.

Enumerable.FirstOrDefault Queryable.FirstOrDefault Queryable.FirstOrDefault<TSour

ce>(IQueryable<TSource>)

Last

Returns the last element of a collection, or the last element that satisfies a condition.

Enumerable.Last Queryable.Last

LastOrDefault

Returns the last element of a collection, or the last

element that satisfies a condition. Returns a default value if no such element exists.

Enumerable.LastOrDefault Queryable.LastOrDefault

Single

Returns the only element of a collection or the only element that satisfies a condition. Throws

an InvalidOperationExceptionif there is no element

or more than one element to return.

Enumerable.Single Queryable.Single

SingleOrDefault

Returns the only element of a collection or the only element that satisfies a condition. Returns a default value if there is no element to return. Throws

an InvalidOperationException if there is more than

one element to return.

Enumerable.SingleOrDefault Queryable.SingleOrDefault

 

Converting Data Types

Method Name

Description

More Information

AsEnumerable

Returns the input typed as IEnumerable<T>.

Enumerable.AsEnumerable

 

 

AsQueryable

Converts a (generic) IEnumerable to a

(generic) IQueryable.

Queryable.AsQueryable

Cast

Casts the elements of a collection to a specified type.

Enumerable.Cast

 

Queryable.Cast

OfType

Filters values, depending on their ability to be cast to a specified type.

Enumerable.OfType

 

Queryable.OfType

ToArray

Converts a collection to an array. This method forces query execution.

Enumerable.ToArray

ToDictionary

Puts elements into a Dictionary<TKey,TValue> based on a key selector function. This method forces query execution.

Enumerable.ToDictionary

ToList

Converts a collection to a List<T>. This method forces query execution.

Enumerable.ToList

ToLookup

Puts elements into a Lookup<TKey,TElement> (a one-to- many dictionary) based on a key selector function. This method forces query execution.

Enumerable.ToLookup

------------恢复内容开始------------

Enumerable.Zip

 

将指定函数应用于两个序列的对应元素,以生成结果序列。

 

Element Operations

Method Name

Description

More Information

ElementAt

Returns the element at a specified index in a collection.

Enumerable.ElementAt Queryable.ElementAt

ElementAtOrDefault

Returns the element at a specified index in a collection or a default value if the index is out of range.

Enumerable.ElementAtOrDefault Queryable.ElementAtOrDefault

First

Returns the first element of a collection, or the first element that satisfies a condition.

Enumerable.First Queryable.First

FirstOrDefault

Returns the first element of a collection, or the first element that satisfies a condition. Returns a default value if no such element exists.

Enumerable.FirstOrDefault Queryable.FirstOrDefault Queryable.FirstOrDefault<TSour

ce>(IQueryable<TSource>)

Last

Returns the last element of a collection, or the last element that satisfies a condition.

Enumerable.Last Queryable.Last

LastOrDefault

Returns the last element of a collection, or the last

element that satisfies a condition. Returns a default value if no such element exists.

Enumerable.LastOrDefault Queryable.LastOrDefault

Single

Returns the only element of a collection or the only element that satisfies a condition. Throws

an InvalidOperationExceptionif there is no element

or more than one element to return.

Enumerable.Single Queryable.Single

SingleOrDefault

Returns the only element of a collection or the only element that satisfies a condition. Returns a default value if there is no element to return. Throws

an InvalidOperationException if there is more than

one element to return.

Enumerable.SingleOrDefault Queryable.SingleOrDefault

 

Converting Data Types

Method Name

Description

More Information

AsEnumerable

Returns the input typed as IEnumerable<T>.

Enumerable.AsEnumerable

 

 

AsQueryable

Converts a (generic) IEnumerable to a

(generic) IQueryable.

Queryable.AsQueryable

Cast

Casts the elements of a collection to a specified type.

Enumerable.Cast

 

Queryable.Cast

OfType

Filters values, depending on their ability to be cast to a specified type.

Enumerable.OfType

 

Queryable.OfType

ToArray

Converts a collection to an array. This method forces query execution.

Enumerable.ToArray

ToDictionary

Puts elements into a Dictionary<TKey,TValue> based on a key selector function. This method forces query execution.

Enumerable.ToDictionary

ToList

Converts a collection to a List<T>. This method forces query execution.

Enumerable.ToList

ToLookup

Puts elements into a Lookup<TKey,TElement> (a one-to- many dictionary) based on a key selector function. This method forces query execution.

Enumerable.ToLookup

 

Aggregation Operations

Method Name

Description

More Information

Aggregate

Performs a custom aggregation operation on the values of a collection.

Enumerable.Aggregate Queryable.Aggregate

Average

Calculates the average value of a collection of values.

Enumerable.Average

Queryable.Average

Count

Counts the elements in a collection, optionally only those elements that satisfy a predicate function.

Enumerable.Count Queryable.Count

LongCount

Counts the elements in a large collection, optionally only those elements that satisfy a predicate function.

Enumerable.LongCount Queryable.LongCount

Max

Determines the maximum value in a collection.

Enumerable.Max Queryable.Max

Min

Determines the minimum value in a collection.

Enumerable.Min Queryable.Min

Sum

Calculates the sum of the values in a collection.

Enumerable.Sum Queryable.Sum

posted @ 2021-03-25 23:50  LBO.net  阅读(63)  评论(0编辑  收藏  举报
//返回顶部