How can I force the Linq code I write to be valid according to an XSD schema?



I've got an XSD file that specifies that <my:Stuff> elements can contain <my:Things> elements and that those can in turn contain <my:Item> objects.


Is there any way to prevent Visual Studio from allowing:



Dim MyElement As XElement = <my:Stuff>
<my:Item></my:Item>
</my:Stuff>


and also prevent



Dim MyQuery = From Stuff In myDocument.<my:Stuff>
Select New With {.Items = Stuff.<my:Items>}


Can I actually get Visual Studio to prevent me from writing these invalid elements and queries, or do I have to turn to an XSD-to-VB code generator for that kind of capability?


No comments:

Post a Comment