0
我創建了一個消息對象,其中包含三個屬性,這三個屬性是三個不同實體類型的三個列表。我創建了消息類,因爲我試圖執行搜索,所有這些都會返回符合搜索條件的所有實體。我希望在一次通話中這樣做,而不是三次(每個實體一次)分開通話。它編譯並且客戶端設計器正在生成實體,服務的搜索全部方法,消息對象類,但不生成消息對象屬性。 RIA服務有可能嗎?如果是的話,你能解釋我做錯了什麼,爲什麼?謝謝!RIA服務EF使用實體列表創建MessageObject作爲屬性
服務器端類聲明:
[Serializable]
[DataContract(IsReference = true)]
public class SearchAllMessage
{
[DataMember]
public List<Entity1> Entity1List { get; set; }
[DataMember]
public List<Entity2> Entity2List { get; set; }
[DataMember]
public List<Entity3> Entity3List { get; set; }
}
客戶端設計器生成的代碼:
/// <summary>
/// The 'SearchAllMessage' class.
/// </summary>
[DataContract(Namespace="http://schemas.datacontract.org/2004/07/SharebackMaintenance.RiaService.Web")]
public sealed partial class SearchAllMessage : ComplexObject
{
#region Extensibility Method Definitions
/// <summary>
/// This method is invoked from the constructor once initialization is complete and
/// can be used for further object setup.
/// </summary>
partial void OnCreated();
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="SearchAllMessage"/> class.
/// </summary>
public SearchAllMessage()
{
this.OnCreated();
}
}
服務的方法簽名:
[Invoke]
public SearchAllMessage SearchAll(string fiterA, string filterB, int filterC)
感謝您的幫助Ed!我將[ComplexTypeAttribute]添加到類中,現在在客戶端生成的文件中,我看到「 - 屬性」System.ComponentModel.DataAnnotations.ComplexTypeAttribute「在客戶端項目」MyProject.RiaService「中不可見。您是否缺少裝配參考?我找不到任何具有ComplexTypeAttribute類的Silverlight 4 dll。你知道Silverlight 4的dll有這個屬性嗎?我是否需要將此類添加到MyDomainService.metadata.cs文件中? – zBomb 2012-01-05 15:51:53
順便說一句我有WCF RIA Servics V1.0 SP2 – zBomb 2012-01-05 16:01:54
抱歉,該屬性位於EntityFramework DLL中。直到現在,我還是假定它來自System.ComponentModel.DataAnnotations或WCF RIA程序集。 – 2012-01-05 20:05:00