A
Andrew Hopper
OK. I've seen the discussion in this ng's archives discussing this, but the
last post I've seen on the topic is almost three months old and I haven't
found anything written by a Microsoft employee that seems to address the
issue. I have a table that relates two other tables (many-to-many) using the
primary keys. The "joiner" table has just two columns that contain values
that match the primary key fields of the corresponding tables and is the
child of two relationships that link these fields to the primary keys. In
order to display a list of rows that do not have entries in the "joiner," I
create a DataView using the following expression:
new DataView(sometable,
"ISNULL(Count(Child(relationname).sometableID), 0) = 0",
DataViewRowState.CurrentRows);
Where sometable is one of the parent tables that I want to filter,
relationname is the name of the child relation (these tables can have
multiple relations), and sometableID is the name of the field in the child
table that contains the parent table's primary key. In this case, I'm
basically saying "give me all rows that are not referenced by this table."
By the way, I have to use ISNULL since Count returns null rather than zero
if the table has no rows (kinda counter-intuitive, dontcha think?).
So, on to the problem. Everything is fine with this until I add a row to
this "joiner" table and try to re-create the view. I want my UI to reflect
my addition, but I want the user to be able to roll back by calling
RejectChanges. However, if I don't call AcceptChanges on the "joiner" table
prior to creating my DataView, I get a VersionNotFoundException: "There is
no Original data to access." Using DataViewRowState values other than
CurrentRows does not change this behavior. I need to use the aggregate
function since I want to "count" the rows in the child containing this value
and show only those rows where the child table has no corresponding rows
(unless someone knows of a better way).
Are we not able to generate DataViews using aggregate functions on child
tables when the rows in the child table have not been saved first? Is this a
bug? Is there a workaround that addresses my problem (more specifically, one
that does not involve using the 'for' statement)?
-Andy Hopper
last post I've seen on the topic is almost three months old and I haven't
found anything written by a Microsoft employee that seems to address the
issue. I have a table that relates two other tables (many-to-many) using the
primary keys. The "joiner" table has just two columns that contain values
that match the primary key fields of the corresponding tables and is the
child of two relationships that link these fields to the primary keys. In
order to display a list of rows that do not have entries in the "joiner," I
create a DataView using the following expression:
new DataView(sometable,
"ISNULL(Count(Child(relationname).sometableID), 0) = 0",
DataViewRowState.CurrentRows);
Where sometable is one of the parent tables that I want to filter,
relationname is the name of the child relation (these tables can have
multiple relations), and sometableID is the name of the field in the child
table that contains the parent table's primary key. In this case, I'm
basically saying "give me all rows that are not referenced by this table."
By the way, I have to use ISNULL since Count returns null rather than zero
if the table has no rows (kinda counter-intuitive, dontcha think?).
So, on to the problem. Everything is fine with this until I add a row to
this "joiner" table and try to re-create the view. I want my UI to reflect
my addition, but I want the user to be able to roll back by calling
RejectChanges. However, if I don't call AcceptChanges on the "joiner" table
prior to creating my DataView, I get a VersionNotFoundException: "There is
no Original data to access." Using DataViewRowState values other than
CurrentRows does not change this behavior. I need to use the aggregate
function since I want to "count" the rows in the child containing this value
and show only those rows where the child table has no corresponding rows
(unless someone knows of a better way).
Are we not able to generate DataViews using aggregate functions on child
tables when the rows in the child table have not been saved first? Is this a
bug? Is there a workaround that addresses my problem (more specifically, one
that does not involve using the 'for' statement)?
-Andy Hopper