2010-08-23 32 views
0

我在Silverlight的Web服務/數據庫抽象層方面沒有太多經驗,並且陷入了我的移植工作的一個方面。項目中有一位核心C#開發人員不再參與其中,我正在編寫他編寫的代碼。關於從RIA Services July Preview到RIA Services 1.0更新代碼的快速問題

我正在使用RIA Services 1.0將帶有RIA Services預覽版本的SL3項目上的代碼更新到SL4。我引用RIA_Services_Breaking_Changes.doc文件從該網址我的代碼的轉換工作: http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3570

我掛機是什麼,我認爲是一個潛在的自動生成的文件,涉及到RIA服務EntityCollection/EntityState東西錯誤。

HerculesModel.metadata.cs(開始轉換前)

namespace Everest.Domain.Hercules 
{ 
    using System; 
    using System.ComponentModel.DataAnnotations; 
    using System.Web.Ria; 
    using System.Web.Ria.Data; 
    using System.Web.DomainServices; 
    using System.Data; 
    using System.Data.Objects.DataClasses; 

    // The MetadataTypeAttribute identifies AuthenticationTypesMetadata as the class 
    // that carries additional metadata for the AuthenticationTypes class. 
    [MetadataTypeAttribute(typeof(AuthenticationTypes.AuthenticationTypesMetadata))] 
    public partial class AuthenticationTypes 
    { 
     // This class allows you to attach custom attributes to properties 
     // of the AuthenticationTypes class. 
     // 
     // For example, the following marks the Xyz property as a 
     // required field and specifies the format for valid values: 
     // [Required] 
     // [RegularExpression("[A-Z][A-Za-z0-9]*")] 
     // [StringLength(32)] 
     // public string Xyz; 
     internal sealed class AuthenticationTypesMetadata 
     { 
      // Metadata classes are not meant to be instantiated. 
      private AuthenticationTypesMetadata() 
      { 
      } 
      public EntityState EntityState; 
      public EntityCollection<LoginAccounts> LoginAccounts; 
      public int TypeId; 
      public string TypeName; 
     } 
    } 
    ... 
} 

我更新了使用引用在斷裂中列出的新的命名空間上面的修改文檔,並測試了構建。 Visual Studio中則列出了以下錯誤274倍的文件中:

Error 53 'EntityCollection' is an ambiguous reference between 'System.ServiceModel.DomainServices.Client.EntityCollection<Everest.Domain.Hercules.BookmarkedProfiles>' and 'System.Data.Objects.DataClasses.EntityCollection<Everest.Domain.Hercules.BookmarkedProfiles>' C:\...\Everest.Domain.Hercules\HerculesModel.metadata.cs 872 11 Everest.Domain.Hercules 
Error 189 'EntityState' is an ambiguous reference between 'System.ServiceModel.DomainServices.Client.EntityState' and 'System.Data.EntityState' C:\...\Everest.Domain.Hercules\HerculesModel.metadata.cs 3501 11 Everest.Domain.Hercules 

所以我更新的代碼,添加預選賽消除歧義:

namespace Everest.Domain.Hercules 
{ 
    using System; 
    using System.ComponentModel.DataAnnotations; 
    using System.ServiceModel.DomainServices.Server; 
    using System.ServiceModel.DomainServices.Hosting; 
    using System.ServiceModel.DomainServices.Client; 
    using System.ServiceModel.DomainServices; 
    using System.Data; 
    using System.Data.Objects.DataClasses; 
    [MetadataTypeAttribute(typeof(AuthenticationTypes.AuthenticationTypesMetadata))] 
    public partial class AuthenticationTypes 
    { 
     internal sealed class AuthenticationTypesMetadata 
     { 
      private AuthenticationTypesMetadata() 
      { 
      } 
      public System.ServiceModel.DomainServices.Client.EntityState EntityState; 
      public System.ServiceModel.DomainServices.Client.EntityCollection<LoginAccounts> LoginAccounts; 
      public int TypeId; 
      public string TypeName; 
     } 
    } 
    ... 
} 

試圖建立我收到的代碼後下面的一般錯誤160次,我完全卡在這些TEntity錯誤:

Error 28 The type 'Everest.Domain.Hercules.Authentication.LoginAccounts' cannot be used as type parameter 'TEntity' in the generic type or method 'System.ServiceModel.DomainServices.Client.EntityCollection<TEntity>'. There is no implicit reference conversion from 'Everest.Domain.Hercules.Authentication.LoginAccounts' to 'System.ServiceModel.DomainServices.Client.Entity'. C:\...\Everest.Domain.Hercules\Authentication\AuthenticationModel.metadata.cs 358 85 Everest.Domain.Hercules 

我有ReSharper的安裝了Visual Studio 2010中,它指出,僅使用由文檔使用的指令是System和System.ComponentModel.DataAnnotations。據我所知* .metadata.cs文件是自動生成的,但我如何重新生成元數據文件,支持這個新版本的RIA服務?這個項目使用了一個開源的MVVM框架。

非常感謝您爲我提供的任何幫助!

回答

0

你不應該在你的using語句中包含S.SM.DS.Client。客戶端程序集只應該鏈接到Silverlight項目中。

Kyle