Answer the question
In order to leave comments, you need to log in
How to link a table to itself and add additional data to EF?
We have the essence of the product (product). Additional modules (or may not be inserted) can be inserted into this product, which in themselves are products (products). Also, the product itself can be inserted into another product:
public class Product : INotifyPropertyChanged
{
public int ProductId { get; set; }
/// <summary>
/// В какие модули можно вставлять
/// </summary>
public virtual ObservableCollection<Product> ForProducts { get; set; }
/// <summary>
/// Какие модули можно вставлять в меня
/// </summary>
public virtual ObservableCollection<Product> AddModules {get; set;}
.....другие поля
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>().HasMany(x => x.AddModules).WithMany(y => y.ForProducts)
.Map(x => x.ToTable("ProductToProduct"));
}
//сколько штук данного продукта(изделия) можно вставить в другой продукт(изделие)
public int Count {get;set;}
// единица измерения (штуки, комплекты и тд.)
public string Unit{get;set;}
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question