Comments (7)
Hi @Tyler-V ! Does this work? I'm away from my computer.
public async Task<List<Package>> GetPackagesAsync(List<int> list1, List<string> list2)
{
return await _context.Package
.Where(p =>
_context.AsQueryableValues(list1).Contains(p.p1) &&
_context.AsQueryableValues(list2, true).Contains(p.p2))
.ToListAsync();
}
I believe your original query should behave the way your are asking (AND
)... Are p.p1
and p.p2
nullable?
from blazartech.queryablevalues.
Hey @yv989c we tried that and it still pulls more records than necessary because the two lists are independent of each other
i.e.
In the database,
1 / ABC
1 / XYZ
List list1 = { 1 }
List list2 = { "ABC" }
We would want packages that only contain 1 and ABC, but this is pulling back 1 and XYZ as well,
We are using something like this now to get desirable results, not sure if there is a better way
var packages = await _context.Package
.Where(p => _context
.AsQueryableValues(accumulations.Select(a => a.nm1), true)
.Contains(p.p1 + "_" + p.p2))
.ToListAsync();
[NotMapped] public string nm1 => p1 + "_" + p2;
from blazartech.queryablevalues.
Does either p.p1
or p.p2
allow nulls?
from blazartech.queryablevalues.
No nulls will exist in either set
from blazartech.queryablevalues.
I'm confused because of the word "set"... not sure if you are referring to the input list or your entity's properties. Would you please clarify? My question is about the two properties on your Package entity. Do you know if the underlying table allow nulls in those fields?
Also, does this give you a different result?
public async Task<List<Package>> GetPackagesAsync(List<int> list1, List<string> list2)
{
return await _context.Package
.Where(p =>
_context.AsQueryableValues(list1).Where(i => i == p.p1).Any() &&
_context.AsQueryableValues(list2, true).Where(i => i == p.p2).Any())
.ToListAsync();
}
from blazartech.queryablevalues.
Hey @Tyler-V , do you have any news about this?
I wasn't able to reproduce your issue on my end. In my test your original query works as expected (get Package
entities where p1
and p2
is present in both list1
and list2
).
I'm wondering if the problem is related to:
- Database null semantics
- The size of your lists
Would you mind sharing the following?
- Version of EF you are using
- The approximate number of elements in each list
- SQL generated by your original query
- The SQL data type and nullability used by
p1
andp2
Thanks.
from blazartech.queryablevalues.
Closing due to inactivity.
from blazartech.queryablevalues.
Related Issues (20)
- Non-intrusive Mode HOT 1
- Json Serialization Support HOT 2
- Naming for Entity Framework 7 and above HOT 1
- MySql support? HOT 2
- Does/Can this work with enum values? HOT 2
- EFCore InternalServiceProvider is not supported HOT 1
- Unable to cast object of type 'BlazarTech.QueryableValues.DeferredInt32Values' to type 'System.String'. HOT 12
- Support for DateOnly/TimeOnly?
- ToQueryString does not work HOT 2
- The generic AsQueryableValues throws if options are provided.. HOT 18
- QueryableValues fails when joining against a query that uses the Include method HOT 2
- Enum Support HOT 3
- Possibility of using implicit version of OpenJson? HOT 3
- Entity Framework Core 8 (.NET 8) Support HOT 7
- Joining entities with table HOT 1
- Better execution plans
- Incompatibility with Microsoft.IO.RecyclableMemoryStream 3.0.0 HOT 4
- EF.Property<T> throws exception with list used in AsQueryableValues() extension HOT 2
- Doesn't work with compiled models
- Question: Nullable columns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazartech.queryablevalues.