Hi
I have the following code:
@using System.ComponentModel.DataAnnotations
<SfGrid DataSource="@projectList">
<GridColumns>
<GridForeignColumn Field="@nameof(project.Customer)" ForeignKeyField="@nameof(customer.Id)" ForeignKeyValue="@nameof(customer.City)"
AllowSorting="true" ForeignDataSource="@customerList" HeaderText="Customer Number">
</GridForeignColumn>
<GridColumn Field=@nameof(project.Cost) HeaderText="Cost"> </GridColumn>
</GridColumns>
</SfGrid>
@code
{
List<project> projectList = new List<project>();
List<customer> customerList = new List<customer>();
protected override async Task OnInitializedAsync()
{
customerList = new List<customer>
{
new customer {Id = "1", Name = "Test1", City = "NY"},
new customer {Id = "2", Name = "Test2", City = "LA"}
};
projectList = new List<project>
{
new project
{
Customer = customerList[0],
Cost = 100
},
new project
{
Customer = customerList[1],
Cost = 150
}
};
}
public class project
{
public customer Customer { get; set; }
public int Cost { get; set; }
}
public class customer
{
[Key]
public string Id { get; set; }
public string Name { get; set; }
public string City { get; set; }
}
}
Im using EFcore 5 to generate the database schema. EF creates a column called customerId in my project table. this property is not accessible via code. only the customer object is.
Now I want to display the customers city in my grid. How do I do this?