Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
RelationMapping-src-1.0.0.zip | 2010-10-12 | 36.6 kB | |
README.md | 2010-10-11 | 3.1 kB | |
RelationMapping.dll | 2010-10-11 | 14.8 kB | |
Totals: 3 Items | 54.6 kB | 0 |
RelationMapping - Enabling quick lookup of an ADO.NET DataSet
's DataRelation
s based upon participating DataColumn
s
License
Apache License 2.0
Summary
A small class meant to be used with any ADO.NET DataSet
in order to create a quick lookup of a DataRelation
based upon its ParentColumns
and ChildColumns
.
Background
ADO.NET Typed DataSets
have Properties
and Methods
for getting their related DataRow
s (accessible through their DataRelations
) which are auto-generated by the MSDataSetGenerator
custom tool. When there is only one DataRelation
linking two DataTable
s, this comes out clearly as either a Property
named "<parent <code>DataTable name>Row
" (e.g. PersonRow
) or a Method
named "Get
<child <code>DataTable name>Rows()
" (e.g. GetAddressRows()
). This is easy to read and the developer needs no knowledge of the DataRelation
's name (e.g. Person_FK04
) However, if there are two or more DataRelations linking the same two DataTables
, the auto-generated Properties
get named "<parent DataTable name>RowBy<DataRelation name>" (e.g. AddressRowByPerson_FK04
). This becomes extremely difficult to use, as getting the correct AddressRow
requires knowing the name of the DataRelation
that it is linked by. In this case, it is in the developer's best interest to make alias Properties
whose names contain the way they are used (e.g. a HomeAddressRow
Property
simply passing through to the auto-generated Property
AddressRowByPerson_FK04
) This makes the code much more readable and manageable. However, this is tedious and requires looking up what the Database creation tool decided to name the relationship of interest. Furthermore, since the DataRow
is being looked up by its DataRelation
name, if the name of that DataRelation
ever gets changed, the alias Property
would then be out of sync, and bugs would be introduced. As a solution, RelationMapping
is a class meant to be used with any DataSet in order to create a quick lookup of the DataSet
's DataRelations
based simply upon its ParentColumns and ChildColumns. This removes the need for developer to ever hard-code the RelationName
into any of the code, hence increasing the readability and robustness of the code.
Key Features
- Get a
DataRelation
via itsParentColumns
andChildColumns
Usage
- Get a
DataRelation
via itsParentColumns
andChildColumns
Dim ds = New TypedDataSet1() Dim rm = New RelationMapping(ds) Dim foundRelation = rm.GetRelation(ds.DataTable1.Column1, ds.DataTable2.Column3)
How to Build
This library and associated unit tests were developed in VS 2008 as standard Desktop projects.
Releases
- 1.0
- 2010-10-11
- Initial release
Author: Chris Tossing <ctossing@kdsecure.com>
Copyright: (c) 2010 by KD Secure, LLC
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.