使用 Linq 从另一种方法对存储过程结果进行排序
Sorting Stored Procedure Results using Linq from another method
有什么方法可以获得我想要的结果吗?我所看到的只是它一直在传递来自另一个的值,但 linq 代码不起作用。我对 C# 很陌生,所以我还不习惯。对不起。
public List<BranchCinemaScheduleSelectStartEndTime> GetMoviesBranchCinemas(DateTime startTime, DateTime endTime,int branchKey)
{
List<XScheduleFromDate> GetRecords = new List<XScheduleFromDate>();
List<BranchCinemaScheduleSelectStartEndTime> branchSchedule = new List<BranchCinemaScheduleSelectStartEndTime>();
// getting the results of my stored procedure
GetRecords = XML_GetMoviesFromBranch(startTime, endTime, branchKey);
// trying to linq but it's not working
IEnumerable query = from bs in GetRecords.ToList()
where bs.Cinemas == "Cinema 1"
select bs;
您必须执行查询才能获得如下结果或
您可以使用以下代码过滤记录。它将 return 电影院 == "Cinema 1"
的记录
var filteredRecords = (from bs in GetRecords
where bs.Cinemas == "Cinema 1"
select bs).ToList();
OR
var filteredRecords = GetRecords.Where(r=>r.Cinemas == "Cinema 1").ToList();
有什么方法可以获得我想要的结果吗?我所看到的只是它一直在传递来自另一个的值,但 linq 代码不起作用。我对 C# 很陌生,所以我还不习惯。对不起。
public List<BranchCinemaScheduleSelectStartEndTime> GetMoviesBranchCinemas(DateTime startTime, DateTime endTime,int branchKey)
{
List<XScheduleFromDate> GetRecords = new List<XScheduleFromDate>();
List<BranchCinemaScheduleSelectStartEndTime> branchSchedule = new List<BranchCinemaScheduleSelectStartEndTime>();
// getting the results of my stored procedure
GetRecords = XML_GetMoviesFromBranch(startTime, endTime, branchKey);
// trying to linq but it's not working
IEnumerable query = from bs in GetRecords.ToList()
where bs.Cinemas == "Cinema 1"
select bs;
您必须执行查询才能获得如下结果或 您可以使用以下代码过滤记录。它将 return 电影院 == "Cinema 1"
的记录 var filteredRecords = (from bs in GetRecords
where bs.Cinemas == "Cinema 1"
select bs).ToList();
OR
var filteredRecords = GetRecords.Where(r=>r.Cinemas == "Cinema 1").ToList();