API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Dataclasses how much do they do?

... 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).

created Oct 27, 2011 by jesperordrup
0% Accept Rate
Q 3 A 2 C 0

1 Answer

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,
answered Oct 27, 2011 by Christian Estrup
Visma e-conomic A/S