使用通用列表,arrayList
Using generic list, arrayList
我要在函数中填写class金额。我不知道如何单独添加 AmountDetail。
我写的代码有错误。我无法列出金额 class。
public class Amount
{
public int Id{ get; set; }
public AmountDetail AllList { get; set; }
public int TotalCount { get; set; }
public int Top { get; set; }
public int Page { get; set; }
}
public class AmountDetail
{
public int Name{ get; set; }
public int Surname{ get; set; }
}
public IHttpActionResult BildirimTumListeGetir(AmountDetail model)
{
List<AmountDetail > amountDetail = new List<AmountDetail >();
List<Amount> detailList= new List<Amount>();
using (var ctx = new ktdbEntities())
{
var query = ctx.amountList().ToList();
var count = query.Count;
var total = ctx.amountListTotal(model.Id).ToList();
model.TotalCount = total.Count();
for(var i = 0; i<count; i++)
{
AmountDetail detail= new AmountDetail ();
detail.Name= query[i].Name;
detail.Surname= query[i].Surname;
amountDetail.Add(detail);
}
}
detailList.Add(model);
return Ok(detailList);
}
如果您想将所有金额列表添加到一个详细列表中,那么您可以这样更改代码,
public class Amount
{
public int Id{ get; set; }
public List<AmountDetail> AllList { get; set; }
public int TotalCount { get; set; }
public int Top { get; set; }
public int Page { get; set; }
}
否则你匹配每个 detailList -> amountDetail ,你应该 master-parent id 并找到所有 linq 子查询 listamount 和两个嵌套的 for 循环并添加 detailList.
我要在函数中填写class金额。我不知道如何单独添加 AmountDetail。
我写的代码有错误。我无法列出金额 class。
public class Amount
{
public int Id{ get; set; }
public AmountDetail AllList { get; set; }
public int TotalCount { get; set; }
public int Top { get; set; }
public int Page { get; set; }
}
public class AmountDetail
{
public int Name{ get; set; }
public int Surname{ get; set; }
}
public IHttpActionResult BildirimTumListeGetir(AmountDetail model)
{
List<AmountDetail > amountDetail = new List<AmountDetail >();
List<Amount> detailList= new List<Amount>();
using (var ctx = new ktdbEntities())
{
var query = ctx.amountList().ToList();
var count = query.Count;
var total = ctx.amountListTotal(model.Id).ToList();
model.TotalCount = total.Count();
for(var i = 0; i<count; i++)
{
AmountDetail detail= new AmountDetail ();
detail.Name= query[i].Name;
detail.Surname= query[i].Surname;
amountDetail.Add(detail);
}
}
detailList.Add(model);
return Ok(detailList);
}
如果您想将所有金额列表添加到一个详细列表中,那么您可以这样更改代码,
public class Amount
{
public int Id{ get; set; }
public List<AmountDetail> AllList { get; set; }
public int TotalCount { get; set; }
public int Top { get; set; }
public int Page { get; set; }
}
否则你匹配每个 detailList -> amountDetail ,你应该 master-parent id 并找到所有 linq 子查询 listamount 和两个嵌套的 for 循环并添加 detailList.