-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use Where("...") after calling ToDynamicArray #261
Comments
As long as you are using |
I am not sure what this means? That I can not achieve what I am trying to do and that is: |
Something like: var q = this._context.Set(typeof(Entity1)).AsQueryable();
var result1 = q.Where("Id<10").FirstOrDefault();
var result2 = q.Where("Id> 50").FirstOrDefault(); |
Understand but this will trigger 2 round trips to database. |
You can use: var array = await _context.Set(typeof(Entity1)).Where("Id < 10").ToDynamicArrayAsync<Entity1>();
var result = array.AsQueryable().Where("Id < 10").FirstOrDefault(); Does this work for you? |
No, because I don't know if I have
Logic behind this is importing entities which has relationship:
So when importing I probably want to use your library in a way that was not intended. |
I just found out that using the newly added functionality about Cast (#249) will do the trick. var array = _context.Set(typeof(Entity1)).Where("Id < 10").ToDynamicArray();
var result1 = array.AsQueryable().Select($"Cast(\"{typeof(Entity1).FullName}\")").Where("Id < 10").FirstOrDefault(); Can you try this? |
Outstanding. |
Hi,
I am trying to filter data after query it from database. Something like this:
but I get error:
I also tried this:
but I get error:
Am I doing something wrong, or is this not possible?
Here is also online demo.
The text was updated successfully, but these errors were encountered: