Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Understand linq expression

$
0
0

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.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>