У меня есть этот запросLinq ошибка параметра
public IEnumerable<TimesheetModel> FilterByUserId(IEnumerable<TimesheetModel> obj, int FilterUserId)
{
var query = (from list in obj.Where(x => x.List.Where(x => x.UserId.Equals(FilterUserId)))
select new TimesheetModel
{
TaskDate = list.TaskDate,
List = list.List
}).ToList();
return query;
}
И у меня есть ошибка:
A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'parent or current' scope to denote something else.
Почему эта ошибка и как решить эту проблему?
У меня есть эта модель
public class TimesheetModel
{
public DateTime TaskDate { get; set; }
public IEnumerable<TimesheetListModel> List { get; set; }
public TimesheetModel() { List = new List<TimesheetListModel>(); }
}
И
public class TimesheetListModel
{
public DateTime Date { get; set; }
public bool? InProgress { get; set; }
public string Note { get; set; }
public int ProjectId { get; set; }
public string ProjectName { get; set; }
public string Task { get; set; }
public decimal? TimeWorked { get; set; }
public int? Type { get; set; }
public int UserId { get; set; }
public string UserName { get; set; }
public int? WorkItemId { get; set; }
}
И моя задача фильтрации по UserId эту модель
{
"TaskDate": "2015-01-04T00:00:00",
"List": [
{
"WorkItemId":24,
"ProjectId":3,
"ProjectName":"Hello world",
"UserId":12,
"UserName":"Anatoliy Svetliakov",
"Date":"2015-01-04T22:00:00",
"Task":"#34 : New task test",
"TimeWorked":2,
"Note":null,
"InProgress":false
}
]
}
Пожалуйста, уточните вопрос с требуемым выходом. –
Поскольку вы делаете два раза 'x => x' в своем' from' – Sybren