0

I am using Database first approach to map my tables to entity models. Currently I have two tables, Orders and Products:

Orders: Id, DateCreated

Products: Id, Name, OrderId

As you can see it's a one to many relationship. And I would like to create a view using these two tables and map it to an entity called Order and Products:

public class Order
{
    public int Id {get;set;}
    public DateTime DateCreated {get;set;}
    public IList<Product> Products {get;set;}
}

public class Product
{
    public int Id {get;set;}
    public string Name {get;set;}
}

I know how to map a single property, but have no idea how I would approach it for a list property. Any ideas?

Please note that the tables are slightly more complicated and I HAVE TO use views to map these entities.

1 Answer 1

1

there are a lot of guides on it around the web. one of them is @ msdn site

Replace IList with ICollection and you should be good with that.

Sign up to request clarification or add additional context in comments.

1 Comment

that was very helpful. THANKS!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.