WCF RIA services domain service metadata

喜夏-厌秋 提交于 2019-12-12 05:35:39

问题


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.

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.


回答1:


Use partial classes. You can create partials for your domain service like MyDomainService.cs and 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; }
        }
    }


来源:https://stackoverflow.com/questions/5285851/wcf-ria-services-domain-service-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!