Dataset without a database - editing the .cs file

C

C P

Background: I'm net to .NET and using C#.

I see that I can create an .xsd file at VS.NET will create a corresponding
C# class for me that is a corresponding dataset to my .xsd schema. This
seems perfect for the class I want to construct. I'd like to have consumers
of my Dataset class be able to access my class as a Dataset. I know this
can all be done. However, I'd like to extend the Dataset class that is
autogenerated from my schema to add some functionality. Is there a safe way
to do this? Or, will any change to the DataSet's schema cause the
underlying class to be re-written and thus lose all my code? I suppose I
could add my code to a subclass of the DataSet class... Is what I'm
attempting a bad idea? Is there a better way to approach this?

Thanks,
Chris
 
B

Brad Williams

Yes, changes to generated code will be lost.

You could probably inherit from the dataset class. But that might not be
the best choice, because if you are adding some business logic, then your
new class will probably be "more than" a dataset ... it will be something
you might call a "data access component" or "business component", which
*uses* a dataset. So maybe consider creating a new class that contains the
dataset as one private field in it. It depends on the meaning of the
functionality you want to add, and on the scope of the project.

Brad Williams
 
C

C P

Thanks,

I decided to create my own class with my dataset as a private member. My
class will restrict access to only the relevant properties of the underlying
dataset, and I'll put the additional required functionality in my own class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top