C # syntax help, about general programming

 TEntity Single(Expression<Func<TEntity, bool>> predicate);

Please explain the parameter.

+3
source share
2 answers

So, a lot is going on here, but let's start from the inside:

Func<TEntity, bool>is a delegate that accepts input whose type is shared, so we just call it TEntity. Without any contraindications, it can be anything, but strictly typed.

Located on one level Expression<Func<TEntity, bool>>. This is an expression tree that is strongly typed as a delegate that accepts input and returns bool. In other words, it is an expression tree (remember the course of your compilers) that represents a function.

, : TEntity Single(Expression<Func<TEntity, bool>> predicate) - Single, . , .

, Single , , , .

, ?

+8

, "TEntity" ( , ) bool. -:

items.Single(i => i.Id == 1);

Single - , TEntity (, , , .. ). , TEntity , .

0

Source: https://habr.com/ru/post/1781357/


All Articles