joining dataviews?

  • Thread starter Thread starter Gloria Mundi
  • Start date Start date
G

Gloria Mundi

Is it possible to equijoin dataviews directly--as distinct from creating
a new view based on a join of the database tables underyling those
views?

Say we have two dataviews: (a) Assemblies and (b) Parts:

(a): AssemblyID, PartID, Qty
(b): PartID, UnitCost

Is it possible to equijoin the two dataviews on their shared column,
PartID, to arrive at this view:

(c): AssemblyID, PartID, Qty, UnitCost


Thanks!
 
Gloria,

You can manually join two views into a new Data.DataTable client side. But
there is no autmatic way to do it.
 
Hi Gloria,

Indeed, what you're missing is a somewhat smart DataView. Well, so far, this
is not around. There was an example on MSDN of a DataView that did this
(very simple and only for limited use, but maybe with some modifications it
fits your needs, anyway, I couldn't find it anymore, maybe someone has a
link to that page, again.).
Right now, I could imagine those solutions:

1) implement ITypedList and IBindingList: that's what was in that article
2) write a (sorry) ugly methode that creates a new table out of two tables
(of course that method can be generic and doing your equijoin by using the
meta information of the Dataset and some input about which tabels should be
joined...)
3) use expression columns in your dataset (create a new table based on
expressions or modify an existing one to kind of get the data from the other
table with an expression... which is, in my opinion, a flat construct of a
derived attribute)

number 1) and 3) work fine and are not so ugly, even when you manipulate the
data, anyway, number one get's tricky if you want to have a good runtime
behavior because of some implementation details. Number 3) looks kind of
ugly but I think for the moment if possible, it's the easiest solution. Note
that you get some compile time suport (syntactical checks, I think no
semantic checks) when using the typed dataset and the VS.NET dataset
designer.

finally it's worth thinking over if you really need to join your data in the
application or application server or if it's in this case not possible to
let the db do this work. We found that it's a tricky task to decide which
ones are your business entities and to decide where you need some (we say)
use case specific "business entites".

regards

Christian
 
Thanks, Christian, for the three suggestions, and thank you Kathleen for
confirming that there was no existing "automatic" method for joining
dataviews client-side, such as

ResultView = dv1.EquiJoin(dv2, JoinColumnPairs)
or
ResultView = dv1.Join(dv2, JoinColumnPairs, JoinType)

GM
 
Back
Top