ASP.NET Core OData Action with complex type having stream always returns null for the stream
Open
@xuzhg is already working on this.
Since Mar 22, 2022.
followup
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Having asp.netcore odata service that returns an action with the following complex type that has stream property.
public class customerResponse
{
public string Id { get; set; }
public Stream Photo{ get; set; }
public string Name { get; set; }
}
Here is the EDM model that is constructed:
var action = builder.EntityType<company>().Action("exportCustomers");
action.CollectionParameter<string>("customerIds");
action.ReturnsCollection<customerResponse>().;
Now there is a odata controller class that implements the following
[HttpPost]
public List<customerResponse> exportCustomers([FromRoute] string key, ODataActionParameters parameters)
{
IEnumerable<string> custIds = parameters["customerIds"] as IEnumerable<string>;
byte[] byteArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
List<customerResponse> responses = new List<customerResponse>();
foreach (string id in custIds)
{
customerResponse itemResponse =
new customerResponse() { Id = id, Photo = new MemoryStream(byteArray,
0, 4), Name = "ABCD" };
responses.Add(itemResponse);
}
return responses;
}
In the above example after making the call, I always see the property Photo is not present. Only the Id and Name are present in the deserialized response.
Am I missing anything with respect to handling stream with Odata ?
Thanks
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.