Alta
Alta
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
mmmm, it seems like ef core can't translate the query or am I just bad at writting?
List<EntityLienCommandeClientCommandeFournisseur> foo = await this._ctx.LienCommandeClientCommandeFournisseur.AsNoTracking()
.Where(l => lignesClients.Any(c =>
l.NumeroJournalClient == c.NumeroJournal
&& l.NumeroPieceClient == c.NumeroPiece
&& l.NumeroLigneClient == c.NumeroLigne)
).ToListAsync();
List<EntityLienCommandeClientCommandeFournisseur> foo = await this._ctx.LienCommandeClientCommandeFournisseur.AsNoTracking()
.Where(l => lignesClients.Any(c =>
l.NumeroJournalClient == c.NumeroJournal
&& l.NumeroPieceClient == c.NumeroPiece
&& l.NumeroLigneClient == c.NumeroLigne)
).ToListAsync();
That looks close enough, though
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
mmmmmm, that's actually great.. I wonder why we didn't do that anywhere in our code base rather that the ugly stringified trick 🤔 Thanks a lot @ZZZZZZZZZZZZZZZZZZZZZZZZZ 🙏 I'll try that out and close the thread once it works
23 replies
CC#
Created by Alta on 7/9/2024 in #help
EF Core - Where clause on multiple field in object list
Yes, I may have miss explained the problem Both A and B should be equal for a matching record Here, if I read that line correctly, the A from Foo could match with a first Bar and the B from Foo could match with the A of a second Bar, wouldn't it? I'll give it a shot anyway, thank you 🙂
23 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
Works like a charm 👌
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
Again, thanks a lot
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
I'll let the thread open, check out the solution, post my answer and close it if someone ever has the same kind of problem
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
Well, I'll at least check it out 🙂 That sounds like a good idea
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
oh, wow. Didn't know about that. That's cool!
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
linqkit ? I'll look it up
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
i don't know the best approach tbh
eh, you showed up. That alone helped me a lot, thanks 🙂
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
I may just generate a raw sql query with a foreach on the list, lmao for something like
WHERE (Foo = @Foo AND Bar = @Bar)
OR (Foo = @Foo2 AND Bar = @Bar2)
OR -- ...
WHERE (Foo = @Foo AND Bar = @Bar)
OR (Foo = @Foo2 AND Bar = @Bar2)
OR -- ...
doesn't sound a lot better than the string concatenation our colleague told us to do 🤔 (well, it will at least keep the indexes. But that doesn't look like the cleanest nor safest)
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
those two fields are part of the primary key which is composed of 4 fields total
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
thousands of records in the database About 1 to 50ish list items depending on user input (most case should be 1 to 3 list item)
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
I've got a table with 2 cols Foo and Bar My database has those records
| Foo | Bar |
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| Foo | Bar |
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
code side, I have a list looking like
| Foo | Bar |
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| Foo | Bar |
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
I'd like to fetch every record from my database where a corresponding record is found in my list In this example, only
{
Foo : 1,
Bar : 1
}
{
Foo : 1,
Bar : 1
}
would be fetched And .Where(x => x.Foo == argFoo && x.Bar == argBar) would work just fine if I only one pair of argument to match the records from But here, I'd like something more akin to a list.Contains(dbRecord)
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
I'll give a bit more context
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
yeah, although it works, that really sounds like a bad option, ngl
30 replies
CC#
Created by Alta on 4/22/2024 in #help
EF Core Where on multiple fields
That works just fine! Until I try and match against records from a list where my db record should be equal to at least a record from my list That's where I'm hitting a wall
30 replies
CC#
Created by Alta on 12/20/2022 in #help
❔ How to organise mappers
thank for the input, toddlahakbar 🙂 May I ask about the relative scope of those projects? 🤔
9 replies
CC#
Created by Alta on 12/1/2022 in #help
❔ Conditional data seed
thank you 🙂
6 replies
CC#
Created by Alta on 12/1/2022 in #help
❔ Conditional data seed
That looks like a sound idea
6 replies