如何让我的orderby使用匿名类型工作?

Sco*_*ttG 6 linq

我把什么放在我的订单中?我想按名字订购.我在明确之后移动了orderby因为我读到它需要最后完成.

   var result = (from r in db.RecordDocs
                  where r.RecordID == recordID
                  select new
                             {
                                 DocTypeID = r.Document.DocType.DocTypeID,
                                 Name = r.Document.DocType.Name,
                                 Number = r.Document.DocType.Number
                             }
                 ).Distinct().OrderBy( );
Run Code Online (Sandbox Code Playgroud)

Jac*_*ter 13

做就是了

.OrderBy(doc => doc.Name)
Run Code Online (Sandbox Code Playgroud)