L
LarryF
One purpose of the DataView is to allow the classes that manage the
data to limit the data provided to the classes that consume the data.
The DataView lets you filter by row, but not by column. My data layer
needs to provide two different views of of an XML data table to the
user interface layer, and each different view needs to display
different columns.
In threads in this group I've found three solutions to this problem
mentioned: duplicating the source DataTable, use SQL statements to
select the correct columns, or letting the user of the DataTable or
DataView (such as a DataGrid) do the filtering. Each of these solutions
have problems.
Duplicating the DataTable may work fine for read-only data, but it
doesn't work if users will be editing different views of the data. You
can't allow multiple copies of data to be edited.
Using SQL statements to select different columns works fine for data
that comes from a database, but my data is coming from an XML file.
There is no back-end database that will provide me restricted views of
my data.
You can use a DataGrid's TableStyles property to filter columns, and
any other grid worth using will let you filter by columns. The problem
with letting the data consumer do the filtering is that the consumer
should know only about the data it needs. If the data source has to
rely on the data consumer to filter columns, the data source gives the
consumer more information than it needs, and then it has to hope that
the consumer obeys the rules and doesn't modify the columns it isn't
supposed to.
Out of these three solutions, it seems that the only one that will work
for XML data is the third, hoping that the data consumers will not mess
with columns I think they shouldn't. This isn't a great solution.
Have I missed something, or did the designers of ADO.Net, by not
allowing column filtering, design a system that won't let the database
layer limit the view of the data consumers?
data to limit the data provided to the classes that consume the data.
The DataView lets you filter by row, but not by column. My data layer
needs to provide two different views of of an XML data table to the
user interface layer, and each different view needs to display
different columns.
In threads in this group I've found three solutions to this problem
mentioned: duplicating the source DataTable, use SQL statements to
select the correct columns, or letting the user of the DataTable or
DataView (such as a DataGrid) do the filtering. Each of these solutions
have problems.
Duplicating the DataTable may work fine for read-only data, but it
doesn't work if users will be editing different views of the data. You
can't allow multiple copies of data to be edited.
Using SQL statements to select different columns works fine for data
that comes from a database, but my data is coming from an XML file.
There is no back-end database that will provide me restricted views of
my data.
You can use a DataGrid's TableStyles property to filter columns, and
any other grid worth using will let you filter by columns. The problem
with letting the data consumer do the filtering is that the consumer
should know only about the data it needs. If the data source has to
rely on the data consumer to filter columns, the data source gives the
consumer more information than it needs, and then it has to hope that
the consumer obeys the rules and doesn't modify the columns it isn't
supposed to.
Out of these three solutions, it seems that the only one that will work
for XML data is the third, hoping that the data consumers will not mess
with columns I think they shouldn't. This isn't a great solution.
Have I missed something, or did the designers of ADO.Net, by not
allowing column filtering, design a system that won't let the database
layer limit the view of the data consumers?