我想获得一个按优先级排序的三个属性的列表
我的代码在这里
MyList
.OrderByDescending(p => p.ToDate)
.OrderByDescending(p => p.Number)
.OrderByDescending(p => p.RunDate)
.FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)
但结果不正确.
例如,当MyList包含两个元素:e1,e2和e1.ToDate> e2.ToDate时,结果为e2.
哪个属性应该先来?具有最高优先级(ToDate)或最低优先级(RunDate)的属性?
我有两个这样的课:
public Class Company
{
public IList<Employee> Employees;
}
public Class Employee
{
public Company WorkPlace;
}
Run Code Online (Sandbox Code Playgroud)
当我想保存类公司的对象时:
MongoDatabase Database = MongoServer.GetDatabase("db");
var workPlace = new Company();
var employee = new Employee { WorkPalce = workPlace}
workPlace.Employees = new List<Employee>{ employee };
Database.GetCollection<Company>("company").Save(workPlace);
Run Code Online (Sandbox Code Playgroud)
将抛出StackOverFlow异常.
c# stack-overflow mongodb bidirectional-relation mongodb-.net-driver
在类Person中我与类Position有关系,类Position与类PositionTitle有关系,而PositionTitle有一个名为Title的属性
public class Person
{
public Position Position{get;set;}
}
public class Position
{
public PositionTitle PositionTitle{get;set;}
}
public class PositionTitle
{
public string Title{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我有一个字符串"Person.Position.PositionTitle.Title",我怎么能用这个字符串得到这个人的属性?