Closed gaspropot closed 3 years ago
For which purpose? Maybe better to prepare several mapping schemas? Currently there is no possibility to remap related entities on the fly.
Please let me explain the problem. What I am trying to do is select from a dynamic table, then include another dynamic table to my result which is related to the first table with a one-to-one relationship. So far I have managed to select from my first dynamic table by using the method .TableName($"{dynamic_table_name}"), and now for the next step I need to do something similar so that I include the second dynamic table that is related to the first one, like I try to do with the above linq query. Is there a way to do that?
I would suggest only custom projection:
var query =
from p in _dbContext.MyDbSet.ToLinqToDBTable().TableName($"my_{convention}")
from r in _dbContext.RelatedDbSet.ToLinqToDBTable().TableName($"my_ft_{convention}").LeftJoin(r => r.Parentid == p.Id)
select new MyDbSet
{
Id = p.Id,
...
GetForeignEntity = r
};
var results = query.ToList();
I have decided to go with a different approach in order to reduce complexity. Thank you for trying to help anyways.
For example: