WCF RIA 服务域服务元数据 [英] WCF RIA services domain service metadata
问题描述
我在 Silverlight 应用程序中使用 RIA 服务,并使用 RIA 域服务进行数据传输.我在更新方法、添加方法、在元数据字段上放置数据验证属性等方面对域服务和元数据进行了更改.
I am using RIA services in a silverlight application with a RIA domain service that does data transfer. I have made changes to the domain service and metadata in terms of updating methods, adding methods, putting data validation attributes on the metadata fields, etc.
当我由于添加新表而需要重新生成域服务时,显然生成算法不会保留我的元数据属性或其他域服务方法.有没有办法通过 Visual Studio 保留它?有没有更好的方法来解决这种情况?
When I am in the position where I need to re-generate the domain service due to adding a new table, obviously the generation algorithm doesn't preserve my metadata attributes or additional domain service methods. Is there any way to preserve this via Visual Studio? IS there a better way to address this situation?
现在我复制域服务和元数据文件,重新生成域服务和元数据,然后打开旧文件并将我的更新复制回来.这是皮塔饼.
Right now I copy the domain service and metadata files, regenerate the domain service and metadata then open the old files and copy my updates back. This is a PITA.
推荐答案
使用部分类.您可以为您的域服务创建部分,如 MyDomainService.cs 和 MyDomainService.metadata.cs.
Use partial classes. You can create partials for your domain service like MyDomainService.cs and MyDomainService.metadata.cs.
例如,在 MyDomainService.metadata.cs
for example, in the MyDomainService.metadata.cs
[MetadataTypeAttribute(typeof(Login.Login_Metadata))]
public partial class Login
{
internal sealed class Login_Metadata
{
public Login_Metadata()
{
}
[Display(Description = "Test")]
public string FirstName { get; set; }
}
}
这篇关于WCF RIA 服务域服务元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!