A Ka Sup
Join to other table in LINQKit Predicate
hello, assume that i have a query
The
Subject
connect to Class
through the table ClassSubject
.
Due to some reasons, i cannot get the list subjects in the allClasses
LINQ, so i write this
so here is my question, when i find the class by some subjects name, like ["Ma", "Li"]
, i build a predicate with LINQKit
, it should be something like this
But it's wrong, the func in Or()
belongs to Class
, not Subject
. i need this predicate runs before the listClasses
is defined, but i don't know how to join to the table Subject
.
Can anyone please help me. Thank you!1 replies
❔ Cannot change table from second call
hello, according to this document https://learn.microsoft.com/en-us/ef/core/modeling/dynamic-model, i want to get dynamic model so i create a class that inherited from
IModelCacheKeyFactory
If i want to change table, i just call
and when i call _context.Set<TB1>()
or _context.Database.GetDbConnection()
, the CustomModelCacheKey
will run and the table will be changed from TB1
to TB1_Other
.
Basically, it works perfectly.
But now the problem is, when i do this
The CustomModelCacheKey
will be fired only once on line var tb1 = _context.Set<TB1>();
, and not on line var tb2 = _context.Set<TB2>();
. So, from model TB1 and TB2, i will get data from table TB1_OTher
and TB2
How can i change table from second line var tb2 = _context.Set<TB2>();
like above6 replies