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
Simple.OData.Client.UnresolvableObjectException is throwing exception when trying to get data by a navigational property on a collection on another collection
this is the code that is causing the exception
var client = new ODataClient("http://localhost:7027/odata");
var response = await client.For<Student>()
.Expand(x => x.StudentCourses
.Select(y => y.Course.CourseTextBooks
.Select(z => z.TextBook)))
.Filter(x => x.StudentCourses.Any(y => y.Course.CourseTextBooks
.Any(z => z.TextBook.Title == "BookCourse5")))
.FindEntriesAsync();
Simple.OData.Client.UnresolvableObjectException is throwing exception when trying to get data by a navigational property on a collection on another collection
this is the code that is causing the exception
this is the registration
this are the domain models
`public class Student
{
public int Id { get; set; }
`public class StudentCourses
{
public int StudentId { get; set; }
` public class Course
{
public int Id { get; set; }
`public class CourseTextBooks
{
public int BookId { get; set; }
`public class TextBook
{
public int Id { get; set; }
`public class StudentsController : ODataController
{
private readonly IServiceProvider _serviceProvider;
OData metadata document
<?xml version="1.0" encoding="utf-8"?> <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> <edmx:DataServices> <Schema Namespace="ODataTestApi.Models" xmlns="http://docs.oasis-open.org/odata/ns/edm"> <EntityType Name="Student"> <Key> <PropertyRef Name="Id" /> </Key> <Property Name="Id" Type="Edm.Int32" Nullable="false" /> <Property Name="Name" Type="Edm.String" Nullable="false" /> <NavigationProperty Name="StudentCourses" Type="Collection(ODataTestApi.Models.StudentCourses)" /> </EntityType> <EntityType Name="StudentCourses"> <Key> <PropertyRef Name="StudentId" /> </Key> <Property Name="StudentId" Type="Edm.Int32" Nullable="false" /> <Property Name="CourseId" Type="Edm.Int32" Nullable="false" /> <NavigationProperty Name="Student" Type="ODataTestApi.Models.Student" Nullable="false"> <ReferentialConstraint Property="StudentId" ReferencedProperty="Id" /> </NavigationProperty> <NavigationProperty Name="Course" Type="ODataTestApi.Models.Course" Nullable="false"> <ReferentialConstraint Property="CourseId" ReferencedProperty="Id" /> </NavigationProperty> </EntityType> <EntityType Name="Course"> <Key> <PropertyRef Name="Id" /> </Key> <Property Name="Id" Type="Edm.Int32" Nullable="false" /> <Property Name="Name" Type="Edm.String" Nullable="false" /> <NavigationProperty Name="CourseTextBooks" Type="Collection(ODataTestApi.Models.CourseTextBooks)" /> <NavigationProperty Name="StudentCourses" Type="Collection(ODataTestApi.Models.StudentCourses)" /> </EntityType> <EntityType Name="CourseTextBooks"> <Key> <PropertyRef Name="CourseId" /> </Key> <Property Name="CourseId" Type="Edm.Int32" Nullable="false" /> <Property Name="BookId" Type="Edm.Int32" Nullable="false" /> <NavigationProperty Name="TextBook" Type="ODataTestApi.Models.TextBook" Nullable="false" /> <NavigationProperty Name="Course" Type="ODataTestApi.Models.Course" Nullable="false"> <ReferentialConstraint Property="CourseId" ReferencedProperty="Id" /> </NavigationProperty> </EntityType> <EntityType Name="TextBook"> <Key> <PropertyRef Name="Id" /> </Key> <Property Name="Id" Type="Edm.Int32" Nullable="false" /> <Property Name="Title" Type="Edm.String" Nullable="false" /> <NavigationProperty Name="CourseTextBooks" Type="Collection(ODataTestApi.Models.CourseTextBooks)" /> </EntityType> </Schema> <Schema Namespace="Default" xmlns="http://docs.oasis-open.org/odata/ns/edm"> <EntityContainer Name="Container"> <EntitySet Name="Students" EntityType="ODataTestApi.Models.Student" /> </EntityContainer> </Schema> </edmx:DataServices> </edmx:Edmx>
it is working fine in postman or with the build in httpclient from .net the api is .net 6
The text was updated successfully, but these errors were encountered: