Understand linq expression

  • Thread starter Thread starter first100
  • Start date Start date
F

first100

Guest
I have an entity named ItemBoxSup ( in table on db) and i have a method in which i pass list of items from extern of some type: ItemBoxLists.

What i want to insert a check in or to see if there is atleast an existing item in my db in ItemBoxSup with a flag set to true ,

but i dont sure if i have to write :

_context.ItemBoxSup.Any(y => y.IsActive == true) // using context

or i can use directly

.Any(y => y.IsActive == true) // or more concise

because i dont understand if y is referred to item on table on db and if x is referred to items in the lists that i pass to method.

public void ItemChecks(IEnumerable<ItemBoxSup> ItemBoxLists)
{

var results=context.ItemBoxSup.Include(x => x.ItemBox)
.Where(y => !y.IsDeleted
&& ItemBoxLists.Any(x => x.Id != y.Id
&& x.ItemBoxId == y.ItemBoxId
|| _context.ItemBoxSup.Any(y => y.IsActive == true)).ToList();
// i can write? || Any(y => y.IsActive == true)).ToList()

thanks to those who will help me understand.


www.Photoballot.net

Continue reading...
 

Similar threads

Back
Top