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
I would like to pass a DTO to a service layer without dependencies on Orleans omitting attributes like [Id] or [GenerateSerializer] in the Service Layer DTO. Is there a way to apply these attribute programmatically or perhaps via inheritance as below.
/* Service DTO. No Orleans dependencies */
public class Order {
// DTO properties
}
/* Orleans DTO */
[GenerateSerializer]
public class OrleansOrder : Order{
}
The text was updated successfully, but these errors were encountered:
Only if you decide not to use the Orleans serializer, e.g: use one of the Json-based once like JSON.NET or STJ.
Regarding your example: no that won't work!
But this is overkill in your case in my opinion and would add a lot of ceremony to your code. What i've done in my case is use STJ for all types located in my core domain model namespace.
Just be aware that STJ is one order of magnitude slower than the native serializer and does not give you the same benefits (you lose powerful things such as object reference preservation & cie). See:
In my opinion the performance hit is negligible for most apps since Orleans is still blazing blast (we are talking about nanoseconds). And in my case, since i use F# and everything is immutable over there, i didn't need the reference preservation features. And you can still use the native serializer for types used on performance critical paths.
Once this is said, unless you have hard constraints you may want to consider treating Orleans as a core dependency of your project, just like the other core libraries of .NET. because at the end of the day, Orleans is literally the execution environment of your code. Adding the nuget package is reasonable. The main reason i haven't followed that path is that there are no source generators in F# and writing the attributes manually would have been tedious.
in my opinion, using STJ by default and the native serializer only where you truly need the performance or the guaranteed will give you the best of both world.
I would like to pass a DTO to a service layer without dependencies on Orleans omitting attributes like [Id] or [GenerateSerializer] in the Service Layer DTO. Is there a way to apply these attribute programmatically or perhaps via inheritance as below.
The text was updated successfully, but these errors were encountered: