在 ASP MVC Api 上,我有树命名函数来检索数据,但我想将它们组合到一个请求 StylesAll:{},这是代码。
[ActionName("Styles")]
public IEnumerable<StyleDTO> GetStyles()
{
return from s in db.styles
select new StyleDTO() { Name = s.Name, StyleId = s.StyleId };
}
[ActionName("Labels")]
public IEnumerable<LabelDTO> GetLabels()
{
return from l in db.Labels
select new LabelDTO() { Name = l.Name, LabelId = l.LabelId , image = l.image};
}
[ActionName("Commodity")]
public IEnumerable<CommodityDTO> GetCommodity()
{
return from c in db.Commodities
select new CommodityDTO() { CommodityId = c.CommodityId, CreateDate = c.CreateDate, Name = c.Name, Varieties = ( from v in c.Varieties select new VarietyDTO()
{
CommodityId = v.CommodityId, Name = v.Name, VarietyId = v.VarietyId
}) };
}