我已經通過了與Silverlight和Ria服務相關的基本教程,現在我試圖分支到我以前使用過的模型。Silverlight到RIA服務到企業對象導致構建錯誤
我有一個Silverlight項目,我想使用Ria服務。與我見過的Ria Services教程不同,我希望讓我的域服務在保存我的域實體(使用EF創建)的業務對象(DLL)項目中使用Repository對象。
這裏是一個域服務的示例代碼段我的工作:
[EnableClientAccess()]
public class ContactService : DomainService
{
public List<Contact> ContactSearch(string lastName)
{
ContactRepository rep = new ContactRepository();
return rep.SearchByLastName(lastName);
}
}
聯繫和ContactRepository都在我的業務對象的項目。 ContactRepository爲聯繫實體查詢EF。
當我建,我得到以下錯誤:
The entity 'SilverlightCRM.BusinessObjects.Contact' does not have a key defined. Entities exposed by DomainService operations must have must have at least one property marked with the KeyAttribute.
如果我改變實體生成的代碼與System.ComponentModel.DataAnnotation.Key()
屬性來裝點Contact.ContactID
屬性描述here,我再生成錯誤在我<projectname>.g.cs
文件我的項目包含我的域名服務。
Type of Namespace 'Data' does not exist in namespace 'System' (are you missing an assembly reference?)
由於<projectname>.g.cs
文件自動生成的身材,只是註釋掉行不工作,我有System.Data作爲項目參考。
我在這裏做錯了什麼?我認爲我可以使用這種模式來組織我的解決方案,但是如果我想使用Ria服務,我是否必須改變這些模式?
這樣做後,我現在可以單獨構建2個項目;然而,如果我構建完整的解決方案,我仍然會遇到錯誤。思考? (除了單獨構建:-)) – JamesEggers 2009-11-07 04:19:15