これは正常に動作ラムダ式と私のLINQクエリです:複数テーブルのLINQクエリでOrderBy句を追加するにはどうすればよいですか?
var query = this.context.Blocks.Where(o =>
o.IsActive && o.ProductSizes.Any(x =>
x.SectionProductSizes.Any(y =>
&& y.SectionID == queryCriteria.SectionId y.Section.SizeTypeID == o.SizeTypeID
)
)
);
我々はSectionProductSizesテーブル内DisplayOrder列を上の仕分け追加することができますどのように?このために使用
追加モデルクラス:
public partial class Blocks
{
public int ID { get; set; }
public string Name { get; set; }
public int SizeTypeID { get; set; }
public int DisplayOrder { get; set; }
public virtual ICollection<ProductSize> ProductSizes { get; set; }
}
public partial class ProductSize
{
public int ID { get; set; }
public string Name { get; set; }
public int ProductID { get; set; }
public int ProductSizeID { get; set; }
public int DisplayOrder { get; set; }
public virtual Product Product { get; set; }
public virtual ICollection<SectionProductSize> SectionProductSizes { get; set; }
}
public partial class SectionProductSize
{
public int SectionProductSizeID { get; set; }
public int SectionID { get; set; }
public int ProductSizeID { get; set; }
public int DisplayOrder { get; set; }
public virtual Section Section { get; set; }
}
public class Section
{
public int ProductID { get; set; }
public int SizeTypeID { get; set; }
public int DisplayOrder { get; set; }
}
モデルクラスも –
あなたのブロックは、多くの 'ProductSize'を含むことができ、自分の順番のものは'多くを含むことができますSectionProductSize'では、注文をどのように決定するのですか? –