WhereBulkContains method supports checking Ids for multiple fields
It's throwing an error now "Oops! only 1 key name is currently supported." Code:
var ids = new List<string> {"id1", "Id2"};
entities.WhereBulkContains(ids, new List<string> {"Field1", "Field2"});
Is support for such functionality being considered?
Hello @pvarets00101 ,
You currently have a list of strings but are trying to use two keys.
The code already works if your list contains entities, for example:
var list = new List<Inventory>() { new Inventory() { ID = 1, ColumnInt = 0 } };
var results = context.Inventories.WhereBulkContains(list, new List<string>() { "ID", "ColumnInt" }).ToList();
So, if you need to map the same value to multiple keys, you can use something like an anonymous type and duplicate the value instead of a simple list of strings.
Best Regards,
Jon
Hello @JonathanMagnan Thanks for the answer.
Yes, I know there is such a way, but creating a new List<Inventory>() { new Inventory() { ID = 1, ColumnInt = 0 } } with more than 10k entries is too expensive. I know that the WhereBulkContains method supports the following functionality
var items = dbContext.Set<TEntity>()
.WhereBulkContains(ids, propertyName)
.ToList();
At the time of execution, I only have a List
var propertyNames = new List<string> { "Id", "ParentId", ...};
var items = dbContext.Set<TEntity>()
.WhereBulkContains(ids, propertyNames)
.ToList();
I would like such functionality. Maybe I don't fully understand.
Hello @pvarets00101 ,
You’re probably also looking for an OR condition instead of an AND, such as Field1 = id OR Field2 = id.
If that’s the case, unfortunately, we currently don’t support this scenario. We have a lot of new features planned for 2026, but for now, this specific case isn’t supported. We’ll make sure to add your request to our backlog.
Best Regards,
Jon