Page 1 of 1
How to define anonymous types?
Posted: Thu Sep 19, 2024 6:51 am
by HansjoergP
To use Dapper you need anonymous types. How can you define these in X#? In C# the syntax is e.g. new {x = ‘test’}
Thanks
Hansjörg
Re: How to define anonymous types?
Posted: Thu Sep 19, 2024 7:23 am
by FFF
A look for "anonymous" into X# help provides:
The syntax for an anonymous class is :
VAR o := CLASS { Name := "test", Value := "something" }
Is that, what you need?
Re: How to define anonymous types?
Posted: Thu Sep 19, 2024 8:20 am
by HansjoergP
Thanks. Yes this is what I need
Re: How to define anonymous types?
Posted: Thu Sep 19, 2024 5:06 pm
by robert
HansJoerg,
If you're filling an anonymous type from another object then you don't need to include the names
Code: Select all
CLASS {Customer.ID, Customer.Name, Customer.DateOfBirth}
This will use the names of the properties as name of the properties in the anonymous type.
Robert
Re: How to define anonymous types?
Posted: Thu Sep 19, 2024 5:07 pm
by rwooters
The syntax in X# is close but not exact:
X#: CLASS {x := "test"}
C#: new {x = ‘test’}