Reputation: 3485
After having created a Typed DataSet for a given set of database tables (using System.Data.Design.TypedDataSetGenerator).
I can attach the generated C# file with
// VsProj is of type VsLangProj.VSProject for the current project
// artifactPath is the path to the newly created C# artifact with the
// typeddataset generated
// code.
VsProj.Project.ProjectItems.AddFromFile(artifactPath);
However when trying to open this in the designer it fails (it is certainly missing the .xsd, .xsc, .xss files). Is there a documented way to get the .xsc / .xss files?
Upvotes: 1
Views: 681
Reputation: 3485
Ok, I found it, instead of using System.Data.Design.TypedDataSetGenerator, just set some magic properties for the ProjectItem and voila:
// xsdPath is a path to a .xsd file which was generated with System.Data.DataSet.WriteXmlSchema.
ProjectItem pi = _vsProj.Project.ProjectItems.AddFromFile(xsdPath);
// this little magic replaces having to use System.Data.Design.TypedDataSetGenerator pi.Properties.Item("SubType").Value = "Designer";
pi.Properties.Item("CustomTool").Value = "MSDataSetGenerator";
(Of course if you were outside of Visual Studio, then it's better the previous method).
Upvotes: 1