Doubt in a lambda expression returning "true"

Asked

Viewed 65 times

3

When I do that:

List<Tipo1> tipo = await context.MeuMetodo.Find(x => true).ToListAsync();

What am I saying here: (x => true)?

  • is hibernate? ...

  • Look what the database is? this code is apparently strange (no need to find and then ToListAsync is already direct !!! In Mongodb exists Find but, Entity Framework I don’t know.

1 answer

3


In this context we must take everything, therefore the result of the expression in every element that the Find() filtra is true, so do not filter anything, pass everything. See if you can just delete the Find().

Only I do not say because it can depend on the LINQ provider and without it something may go wrong, but in general it should have no use and can only do:

List<Tipo1> tipo = await context.MeuMetodo.ToListAsync();

I put in the Github for future reference.

Or even that.

Unless there’s something I don’t know.

  • Taking Find() gives error

  • That’s what I said, the preview may require.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.