-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use polymorphism on return type of grpc code first service? #319
Comments
I think maybe related to #300 |
I ask same question on Stack Overflow https://stackoverflow.com/q/77704495/1539100 |
related to BSVN/Commons#68 |
@mgravell response in stack overflow like below If you can't alter RuntimeTypeModel.Default.Add(typeof(BaseResponse), false)
// fields of BaseResponse
.Add(1, nameof(BaseResponse.hoo))
// sub-types of BaseResponse
.AddSubType(10, typeof(ResponseA))
.AddSubType(11, typeof(ResponseB)); Here I'm assuming that [ProtoContract]
public class ResponseA : BaseResponse
{
[ProtoMember(1)]
public string foo;
} If that isn't possible, you'll also need to configure them manually, for example: RuntimeTypeModel.Default.Add(typeof(ResponseA), false)
.Add(1, nameof(ResponseA.foo)); |
For automated this procedure, I write some attribute like below
@mgravell Did you want to I create a PR for this helper and attribute? |
ITNOA
I want to use polymorphic return type in grpc service with code first approach, but I do not know how to do it?
I have service contract like below
And I have two derived response like below
my
BaseResponse
exist in another library, and I do not want (and I can not) to change this library.So finally I want to implement
SayHello
like belowBut I do not know how can I say to
OperationContract
that I have two type for return type?The text was updated successfully, but these errors were encountered: