C
C P
I've got a class (MyClass) that has a DataSet (privateDataSet) as a private
property. I'd like to give consumers of MyClass read-only access to a
couple of the DataTables in the privateDataSet, as DataTables. What I'm
thinking of doing is creating a public property MyClass.MyDataTable that
returns a clone of a DataTable in privateDataSet. That way if the user
messes around with MyClass.MyDataTable, they won't be changing any of the
data in the underlying DataTable.
However, I see that DataTable has a readonly property 'DataSet' which I
assume will point back to the DataSet that I'm trying to keep hidden. If I
call "MyClass.MyDataTable.DataSet.Clear()", will that get rid of the DataSet
associated with my MyClass.MyDataTable, without affecting the underlying
privateDataSet? Will my cloned DataTable in MyClass.MyDataTable still have
data when it's corresponding DataSet has been cleared?
If what I'm talking about above won't work, is there a way to expose a clone
of a DataTable, without including the original DataTable's Dataset?
Thanks,
Chris
property. I'd like to give consumers of MyClass read-only access to a
couple of the DataTables in the privateDataSet, as DataTables. What I'm
thinking of doing is creating a public property MyClass.MyDataTable that
returns a clone of a DataTable in privateDataSet. That way if the user
messes around with MyClass.MyDataTable, they won't be changing any of the
data in the underlying DataTable.
However, I see that DataTable has a readonly property 'DataSet' which I
assume will point back to the DataSet that I'm trying to keep hidden. If I
call "MyClass.MyDataTable.DataSet.Clear()", will that get rid of the DataSet
associated with my MyClass.MyDataTable, without affecting the underlying
privateDataSet? Will my cloned DataTable in MyClass.MyDataTable still have
data when it's corresponding DataSet has been cleared?
If what I'm talking about above won't work, is there a way to expose a clone
of a DataTable, without including the original DataTable's Dataset?
Thanks,
Chris