Using Azure Durable Functions, I am trying to use the context.GetInput<model>()
function which returns the specified model. The model being used has a parameter that is another model which is a derived class. The model that is outputted from context.GetInput<model>()
returns the model with the base class instead of the derived class.
I have checked the $type specified in the context, which shows the derived class, but when checking the outputted model, the result is the base class.
for example:
public class Student{
public Book book {get;set;}
}
public class Textbook:Book {
public string classfor {get;set;}
}
public class Book {
public string title {get;set;}
}
[ActivityTrigger] DurableActivityContextBase context
is a parameter to the function.
Then I would be calling :
var model = context.GetInput<Student>()
where the context includes
{
"$type": "Student",
"book" : {
"$type": "Textbook",
"classfor" : "Math",
"title" : "PreAlgebra"
}
}
Yet the result is Model of student which contains a Book instead of Textbook, where the title is assigned "PreAlgebra"
I expect the output of Student model to have a Textbook with properties:
title = "PreAlgebra"
classfor = "Math"
but the actual Student output contains a Book with the property
title = "PreAlgebra"