❔ Access a DB property from a not mapped property
I have 2 models, A and B.
A includes a property X that I want to store in property Y in B.
Property X is stored in a DB, property Y is not mapped.
How can I achieve this? Simply doing
get => A.X
does not seem to work in property Y11 Replies
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Just realized I totally messed up the question.
Class A has this property
[ForeignKey("ArticleID")]
public ArticleModel Foo {
get => Get(ref article);
set => Set(value, ref article);
}
private ArticleModel article = null;
Which references this property in class B:
[ForeignKey("KindID")]
public KindModel Bar {
get => Get(ref kind);
set => Set(value, ref kind);
}
private KindModel kind = null;
Now in class A I want another property of type KindModel
that stores the value of Bar, which is the same type.Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yeah so that is the issue I think, those are self written methods for lazy loading:
protected virtual T Get<T>(ref T backingField, [CallerMemberName] string name = null) where T : LazyLoaderModel {
TeBeCo
what library are you using to access the data
Quoted by
<@689473681302224947> from #Access a DB property from a not mapped property (click here)
React with ❌ to remove this embed.
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
EF Core is used to access sqlite db, we use lazy loading because what our data models is only usefull in its entirety
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
If you use all the data... load all the data, eagerly
Why have 7142 round trips to the database when 1 trip will do?
Or use graphql + EF core, if your system cannot have a stable set of required data
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.