You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using immutable value objects that wraps primitives with validations in our entities.
A value object (VO) could be represented as the following:
publicrecordCustomerName{publicstringValue{get;}publicCustomerName(stringvalue){if(string.IsNullOrWhiteSpace(value)){thrownew ValidationException("CustomerName can't be empty.");}value= Normalize(value);if(value.Length >100){thrownew ValidationException("CustomerName exceeds the maximum length of 100 characters.");}Value=value;}publicstatic CustomerName From(stringvalue)=>new(value);publicstringNormalize(stringvalue)=> CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value).Trim();}
99% of our VO are Domain Primitives, they only contain a single property and we don't want to treat them as complex objects, so we use converters in the configuration:
To make a search query translate to Sql, we need to cast the VO as a string because the underlying property Value does not exist in the database and sometimes we have to cast as object before casting as string.
Context
We are using immutable value objects that wraps primitives with validations in our entities.
A value object (VO) could be represented as the following:
99% of our VO are Domain Primitives, they only contain a single property and we don't want to treat them as complex objects, so we use converters in the configuration:
Actual use
To make a search query translate to Sql, we need to cast the VO as a
string
because the underlying propertyValue
does not exist in the database and sometimes we have to cast as object before casting as string.Expected use
We would like to be able to access the underlying property in the query as valid C# code and still generate the correct Sql.
I've made a test case here: adampaquette#1
I would need guidance on how to achieve this.
Thank you
The text was updated successfully, but these errors were encountered: