使用序列化将名称空间添加到自动生成的linq到sql代码 [英] Adding namespace to auto-generated linq to sql code with serialization

查看:51
本文介绍了使用序列化将名称空间添加到自动生成的linq到sql代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在linq to sql designer的属性上将SerializationMode设置为Unidirectional非常棒。这将使用适当的DataContract和DataMember属性修饰生成的类。但是,这些属性不包含
命名空间参数,因此使用的结果命名空间是tempuri.org。我可以手动将参数添加到生成的代码中,但当然,对设计器的任何后续更改都将覆盖这些更改。有没有办法设置要使用的命名空间?

It is really great how you can set the SerializationMode to Unidirectional on the properties of the linq to sql designer. This decorates the generated classes with the appropriate DataContract and DataMember attributes. But, these attributes do not include a namespace parameter, so the resulting namespace used is tempuri.org. I can manually add the parameters to the generated code, but of course, any subsequent changes to the designer will overwrite those changes. Is there any way to set the namespace to use?

请注意,属性表中的Context和Entity Namespace选项不适用于此 - 这些选项处理C#代码命名空间,不是DataContract和DataMember属性使用的服务命名空间。

Note that the Context and Entity Namespace options in the property sheet do not apply to this--these options deal with the C# code namespaces, not the services namespace used by the DataContract and DataMember attributes.

推荐答案

您可以尝试L2ST4 http://l2st4.codeplex.com是一个T4模板,可以用你可以修改它的方式替换LINQ to SQL的代码生成过程。

You could try L2ST4 http://l2st4.codeplex.com which is a T4 template that can replace the code generation process of LINQ to SQL in a way you can modify it.

[)amien


这篇关于使用序列化将名称空间添加到自动生成的linq到sql代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆