I installed a nugget package (targeting the framework 4.6.1) and using it I want to send some invoices.
The class defined for the invoice (installed from nugget):
Each invoice contains a number of items for which a separate class is defined (installed from nugget):
The problem I have is how to give the values of the invoice and its items to the SendInvoices function?
When I try to set the value in the following way, it gives this error:
Member 'P1' cannot be initialized. It is not a field or property.
Member 'P2' cannot be initialized. It is not a field or property.
The class defined for the invoice (installed from nugget):
C#:
[NullableAttribute(0)]
[NullableContextAttribute(1)]
public class InvoiceDao : IEquatable<InvoiceDao>
{
public InvoiceDao();
[CompilerGenerated]
protected InvoiceDao(InvoiceDao original);
public List<InvoiceItemDao> Items { get; set; }
[CompilerGenerated]
public List<InvoiceItemDao> get_Item();
}
Each invoice contains a number of items for which a separate class is defined (installed from nugget):
C#:
[NullableAttribute(0)]
[NullableContextAttribute(1)]
public class InvoiceItemDao
{
public InvoiceItemDao();
public decimal P1 { get; set; }
public string P2 { get; set; }
.
.
.
[CompilerGenerated]
public decimal get_P1();
[CompilerGenerated]
public string get_P2();
}
The problem I have is how to give the values of the invoice and its items to the SendInvoices function?
C#:
InvoiceDao invoiceDao = new InvoiceDao();
var invoices = new List<InvoiceDao>
{
//how to initialize invoiceDao ??
};
SendInvoices(invoices, null);
When I try to set the value in the following way, it gives this error:
Member 'P1' cannot be initialized. It is not a field or property.
Member 'P2' cannot be initialized. It is not a field or property.
C#:
var Item= new InvoiceItemDao
{
P1= "110",
P2="Name"
};
var invoices = new List<InvoiceDao>
{
new()
{
Items= new() {Item}
}
};