我有一个包含Person
这样的模型的列表:
public class Person
{
[Key]
public int Id { get; set; }
public int Rating1 { get; set; }
public int Rating2 { get; set; }
public DateTime CreateDate { get; set; }
}
Rating1
从不等于Rating2
。
问题:
如何获得一个Rating1
或Rating2
等于给定评级值的列表,以及该列表中最后创建的元素?
我通过样本解释我的观点。假设这里是列表:
Rating1 Rating2 CreateDate
4 8 2013-08-15 05:12:00
9 4 2013-08-15 07:12:00
8 4 2013-08-15 08:12:00
5 20 2013-08-15 09:12:00
20 4 2013-08-15 10:12:00
20 5 2013-08-15 11:12:00
4 9 2013-08-15 12:12:00
假设我将评级值“4”作为参数发送到此方法
public IEnumerable<Person> GetList1(int r) {}
并获得一份清单:
8 4 2013-08-15 08:12:00 //because there are many [4 and 8] couples, but this created last.
4 9 2013-08-15 12:12:00 //because there are many [4 and 9] couples, but this created last.
20 4 2013-08-15 10:12:00 //because there is one [4 and 20] couple, this also created last.
如果我将评级值“20”作为参数发送给 GetList1()
方法,我想得到一个列表:
20 5 2013-08-15 11:12:00 //because there are many [20 and 5] couples, but this created last.
20 4 2013-08-15 10:12:00 //because there is one [20 and 4] couple, this also created last.