C
C#16mo ago
.tree

❔ 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 Y
11 Replies
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
.tree
.treeOP16mo ago
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
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
.tree
.treeOP16mo ago
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 {
MODiX
MODiX16mo ago
TeBeCo
what library are you using to access the data
React with ❌ to remove this embed.
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
.tree
.treeOP16mo ago
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
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius16mo ago
If you use all the data... load all the data, eagerly Why have 7142 round trips to the database when 1 trip will do?
Denis
Denis16mo ago
Or use graphql + EF core, if your system cannot have a stable set of required data
Accord
Accord16mo ago
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.
Want results from more Discord servers?
Add your server