Answer the question
In order to leave comments, you need to log in
How to design such Code First?
Shalom. Cash register simulation.
There are 3 classes.
Check, Product, ProductItem.
Check - is a check; contains all information about purchases. Inside the ProductItem collection .
ProductItem - Connecting entity. It has a Product and a Count property.
Product - Contains product information.
Interactive
There is a one-way communication, from top to bottom. And I don't need feedback.
How to describe it in CodeFirst, what would be stored in the norm base?
Answer the question
In order to leave comments, you need to log in
If I understood you correctly, then this is many-to-many (i.e., there can be several products in a receipt, and one product in several receipts) .... If so, then it should look something like this ....
public class Check{
public int Id {get;set;}
public ICollection<ProductItem> ProductItem {get;set;}
}
public class Product{
public int Id {get;set;}
public ICollection<ProductItem> ProductItem {get;set;}
}
public class ProductItem{
public int ProductId {get;set;}
public Product Product {get;set;}
public int CheckId {get;set;}
public Check Check {get;set;}
public int Count {get;set;}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question