如何将 C# 中的代码与传递的参数合并
本文关键字:参数 合并 代码 | 更新日期: 2023-09-27 17:57:04
是否有可能有这一行
var newlist = listOrder.OrderBy(i => i.Date).ToList().GetRange(jtStartIndex, jtPageSize)
和这行代码一起?
_repository.ReportRepository.GetTracks(jtStartIndex, jtPageSize, jtSorting);
我尝试添加一个运算符,但它不起作用。 即像这样:
var newlist = listOrder.OrderBy(i => i.Date).ToList().GetRange(jtStartIndex, jtPageSize) + _repository.ReportRepository.GetTracks(jtStartIndex, jtPageSize, jtSorting);
完整控制器代码:
[HttpPost]
public JsonResult StudentList(string StartDate = "", string EndDate = "", int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
{
try
{
if (Request.IsAuthenticated == true)
{
string Path = @"C:''5Newwithdate-1k.xls";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= '" + Path + "';Extended Properties=" + (char)34 + "Excel 8.0;IMEX=1;" + (char)34 + "");
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
con.Close();
System.Data.DataTable data = new System.Data.DataTable();
da.Fill(data);
List<TopPlayed> daa = new List<TopPlayed>();
foreach (DataRow p in data.Rows)
{
TopPlayed top = new TopPlayed()
{
TrackID = Convert.ToInt32(p.Field<double>("TrackID")),
Date = p.Field<DateTime>("DateTimes"),
TrackName = p.Field<string>("TrackName"),
ArtistName = p.Field<string>("ArtistName"),
Times = Convert.ToInt32(p.Field<double>("Times"))
};
daa.Add(top);
}
// var newlist = listOrder.OrderBy(i => i.Date).ToList().GetRange(jtStartIndex, jtPageSize) _repository.ReportRepository.GetTracks(jtStartIndex, jtPageSize, jtSorting);
var newlist = _repository.ReportRepository.GetTracks(jtStartIndex, jtPageSize, jtSorting).OrderBy(i => i.Date).ToList().GetRange(jtStartIndex, jtPageSize);
return Json(new { Result = "OK", Records = newlist, TotalRecordCount = daa.Count });
我可能正在考虑你想做什么,如果是这样,请告诉我。
var newlist = _repository.ReportRepository.GetTracks(jtStartIndex, jtPageSize, jtSorting).OrderBy(i => i.Date).ToList().GetRange(jtStartIndex, jtPageSize);