2014-11-06 29 views
0

我可以組合複雜屬性和簡單屬性的順序嗎?例如在顯示/編輯器中組合複雜和簡單屬性的順序ForModel

public class Car 
{ 
    public string Color {get;set;} 
    public string Engine {get;set;} 
} 


public class Report 
{ 
    public Car Car {get;set;} 
    public string Name {get;set;} 
} 

和秩序,我使用的是展示要在視圖/ EditorForModel是:

顏色 名稱 引擎

這可能嗎?

感謝

+0

有什麼語言?添加語言標籤。 – 2014-11-06 09:02:08

回答

0

您可以在C#中使用匿名類型,看看下面這個例子: -

Car car = new Car { Color = "Red", Engine = "E1" }; 
      Report report = new Report { Cars = car , Name = "Car1" }; 
      var Result = new { Color = report.Cars.Color, Name = report.Name, Engine = report.Cars.Engine }; 
相關問題