Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why are you extending a DataTable? If you are looking to add methods, you should look into <a href="http://www.dotnetperls.com/extension" rel="nofollow noreferrer">Extension Methods</a>. I am pretty sure the the <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx" rel="nofollow noreferrer">DataTable Class</a> does not have any virtual methods or properties that you could override, and memeber hiding does not work in <a href="http://msdn.microsoft.com/en-us/library/ms173152(v=vs.80).aspx" rel="nofollow noreferrer">polymorphism</a>. <a href="https://stackoverflow.com/questions/12162235/extend-datatable-in-c-sharp">Check out this post</a> for another view on someone that was trying to extend the DataTable as well.</p> <p>Edited:</p> <p>If you are also trying to pass your object through WCF, it must be marked <a href="http://msdn.microsoft.com/en-us/magazine/cc163569.aspx" rel="nofollow noreferrer">Serializable</a>, but this causes some other funky issues, and could possibly be rejected if the base class has some sort of special serialization. In that case marking your derived class as [Serializable] will kick out an error as well.</p> <p>I would seriously consider the <a href="http://www.dotnetperls.com/factory" rel="nofollow noreferrer">Factory Pattern</a> from what you described. That way you have your factory class that builds your table how you want it every time, but it is still a DataTable.</p> <p>If you have any objects (not primitive) in your datatable, you must mark your WCF service to have the "KnownTypes(typeof(MyType))" so that it knows that there is something serialized inside the serialized datatable.</p> <p>One final draw, you should avoid using datatables and datasets in WCF...</p> <p><a href="http://www.hanselman.com/blog/ReturningDataSetsFromWebServicesIsTheSpawnOfSatanAndRepresentsAllThatIsTrulyEvilInTheWorld.aspx" rel="nofollow noreferrer">Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World</a></p> <p><a href="http://blogs.microsoft.co.il/blogs/oshvartz/archive/2011/07/23/wcf-performance-using-datasets-part-2.aspx" rel="nofollow noreferrer">WCF Performance Using Datasets – Part 2</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload