Lazy loading and saving new (empty) entities

Posts   
 
    
timbered
User
Posts: 45
Joined: 09-Feb-2020
# Posted on: 06-Apr-2020 04:08:41   

Using version 5.6

Building my first ORM app, and my first Llblgen app. So, I have 35 years of relational stuff to unlearn. This is probably an RTFM question, but I couldn't find a post on it.

My app has many dark corners that may only apply in certain situations. Like, some records will only use 30% of the 150+ fields, and others will also use 30%, but completely different ones.

So, I really want to use lazy loading, to prevent reads on tables a given record isn't using, obviously.

What do I do about new records?

If I set the flag of "Lazy loading without results returns new" and do

Dim Customer As New CustomerEntity

Customer now is an empty entity, with empty entities attached through relationships. Then, when I

Customer.Save(True)

to do a deep save, all those empty entities get saved as empty records in my tables. I really don't want that.

Whereas if I turn off the "returns new" flag and do "New CustomerEntity", now I have an entity with Nothings hanging off where the related entities should be. I really don't want that either, in that I'd need to proactively keep track of where my user goes and create the related entities only if needed.

So, since I don't want to do either of these, what are my options?

timbered
User
Posts: 45
Joined: 09-Feb-2020
# Posted on: 06-Apr-2020 04:41:25   

Damn... I knew it was an RTFM question.

I'm only getting the empty entities saved in the tables that have a 1:1 relation.

Which, of course, makes sense.

Wherein, if I change it to 1:0..1, I assume that empty one won't be there.

So, thanks for your help anyway!