是否有T4模板可用于从xsd生成c#类? [英] Is there T4 templates available for generating c# classes from xsd?

查看:76
本文介绍了是否有T4模板可用于从xsd生成c#类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有T4模板可用于从xsd生成c#类?

Is there T4 templates available for generating c# classes from xsd?

推荐答案

我不知道,但是看看在LINQ to XSD( http://linqtoxsd.codeplex.com/ )上。您可以使用LinqToXsd.exe根据您的架构生成强类型的类。然后,您还将获得完整的LINQ支持。非常方便。

Not that I know of, but take a look at LINQ to XSD (http://linqtoxsd.codeplex.com/). You can use LinqToXsd.exe to generate strongly typed classes based on your schema. And then you have full LINQ support as well. Very handy.

您还可以在项目中设置一个类似于以下内容的预构建事件:

You could also set up a pre-build event on your project that looks something like:

$(ProjectDir)Lib / LinqToXsd / LinqToXsd.Exe $(ProjectDir)MySchema.xsd /fileName:MySchema.cs

这会在构建之前从架构中生成类,因此,如果更改架构,您的类将与每次构建保持同步。

And that would generate the classes from the schema right before you build, so if you change your schema, your classes will stay in sync with each build.

这篇关于是否有T4模板可用于从xsd生成c#类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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