开发者

Generate LINQ DataContext from XML, XSD, or C# class [closed]

开发者 https://www.devze.com 2023-01-07 19:18 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this question

I have 开发者_JAVA技巧a massive set of classes I need to create from an XML file that I'd really not like to do by hand. What I'd really like to do is somehow generate a LINQ DataContext so I can use VisualStudio to build a SQL database from the DataContext.

I'm aware that I can generate XSD and C# classes from the XML file, but are there any tools to generate proper SQL Database tables or LINQ DataContext from those?


You can use http://xsd2code.codeplex.com/ to generate C# classes from your XSD. Don't forget to enable Serialization and GenerateXMLAttributes. Set ColllectionObject Type to a type that implements ICollection, for instance List, don't use IList.

Next, implement your DbContext as usual.


I don't believe LINQ to SQL supports creating a database from a model of any kind. Entity Framework in .NET 4.0 does.

Also, be aware that not all XML schemas map to valid relational database structures.


Open an XSD file in VS, create a DataSet in VS, then copy the XSD file into the dataset both in designer mode. That'll generate the a typed DataContext.

0

精彩评论

暂无评论...
验证码 换一张
取 消