PDA

View Full Version : بهترین روش برای نمایش چند مدل با هم در یک ویو کدام است



gama_slv
پنج شنبه 11 مهر 1392, 20:36 عصر
میخواستم بدونم بهتر از کدوم روش
Flattening,viewmodel,AutoMapper
برای حل مسئله زیر اسفاده کنم

دو مدل دارم

محصولات

public Products()
{
this.Orders = new HashSet<Orders>();
this.ProductDown = new HashSet<ProductDown>();
}

[Key]
public int ProductID { get; set; }
public int ProductGroupID { get; set; }
public string ProductTitle { get; set; }
public string ProductDescription { get; set; }
public string ProductImageUrl { get; set; }
public string ProductThumbnailImageUrl { get; set; }

public virtual ICollection<Orders> Orders { get; set; }
public virtual ICollection<ProductDown> ProductDown { get; set; }
public virtual ProductGroups ProductGroups { get; set; }
}

نمونه محصولات

public partial class ProductDown
{
[Key]
public int ProductDownID { get; set; }
public int ProductID { get; set; }
public string ProductDownTitle { get; set; }
public string ProductDownDescription { get; set; }
public string ProductDownImage { get; set; }

public virtual Products Products { get; set; }
}
از یک ویو id محصول رو میگیرم و در یک وی فقط همان محصول رو نشون میدم
product id رو برای یک ویو با دو مدل استفاده کنم
میخوام از این دو مدل در یک ویو اسفاده کنم
عکس محصولات در بالا صفحه و تمام عکسهای نمونه محصولات همون محصول در ادامش بیاد