Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataSetToObject improvement when mapping. #133

Open
BimmerR opened this issue Jun 27, 2018 · 2 comments
Open

DataSetToObject improvement when mapping. #133

BimmerR opened this issue Jun 27, 2018 · 2 comments

Comments

@BimmerR
Copy link

BimmerR commented Jun 27, 2018

if not _dict.TryGetValue(_field.Name, field_name) then

Existing line does not allow data from a dataset where fields are "missing".

Change to this - to allow 'SELECT CUSTOMER_ID, CUSTOMER_NAME FROM CUSTOMER' to be used in object of TCustomer with more properties than ID and NAME.

if (not _dict.TryGetValue(_field.Name, field_name)) or (ADataSet.FindField(field_name) = nil) then

@danieleteti danieleteti self-assigned this Jul 2, 2018
@danieleteti
Copy link
Owner

I don't know if this is a good behaviour. This can lead to half-loaded business objects, where the business logic could fail just because the object is not fully loaded. Also this sould lead to some very subtle bugs. What are your use case? Could we solve the problem in another way?

@BimmerR
Copy link
Author

BimmerR commented Aug 19, 2018

It all made good sense when having a wide table (80+ columns) and wanted to select only 10 into a list.
That way you could use the "master" class with all properties and just map what you had selected.
I can see your point in "getting half-loaded" business objects.
The only option I can see otherwise, will be creating a semi-class of my master class - and deal with having multiple classes holding similar data.

If no-one else is in need of this - then please close the issue. I can work around it. :-)

Edit **
Come to think about it - again. A Controller (POST) receiving an object {"foo":"testdata","bar":"moretestdata"} is perfectly correct parsed into
TBusinessObjectFooBar = class FID : integer; FFoo : string; FBar : string; end;

and that leads to half-loaded business objects too ... but I think that it should be up to the developer.
Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants