Dataclasses how much do they do?

Forum for .NET developers using the E-conomic API.
Exchange your ideas, tip and tricks using the API.
Best Practices

Dataclasses how much do they do?

Postby jesperordrup » Thu Oct 27, 2011 9:47 am

... and what are you supposed to do yourself.

Given this:

ICurrentInvoiceData invoiceData = _session.CurrentInvoiceData.Create(debtor);
ICurrentInvoice invoice = _session.CurrentInvoice.CreateFromData(invoiceData);

This will fail because invoiceData.DebtorName is empty.

Why is it that? I've just created invoiceData from debtor.

Is line 1 only to estabish relation?

invoiceData has a property named "Debtor". Am I supposed to equal this with the same debtor that I used to create the object?

Can you recommend any good reading on this?
(I cant find any good examples nor best practice and the document api text is somewhat minimal / autogenerated).

Best
Jesper
-
jesperordrup
 
Posts: 3
Joined: Thu Oct 27, 2011 9:38 am

Re: Dataclasses how much do they do?

Postby Christian Estrup » Thu Oct 27, 2011 10:39 am

Data classes require you to explicitly set all properties.

Basically, this could have been done differently in two ways:

1. When creating a data object, we could automatically populate it with default values. However, that would often require round-trips, thus short-circuitting the concept of using data classes somewhat.

2. When creating entities using data classes, any NULL properties could automatically be set to some default values in e-conomic's end. However, that would be a huge issue with properties that are themselves NULLable - how would e-conomic know whether a particular property being NULL means "I WANT it to be NULL", or "I want it set to some default value"?


Best regards,
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 245
Joined: Tue Jun 09, 2009 6:37 pm


Return to .NET



cron