Here is an example that relies on the fact that .net will automatically create
a relationship between the tables where there are xml nested elements. In your
example person will be a parent of color because the color elements are nested
in the person elements.
string autoRelation;
string childFilter = "";
DataView view = mapData.FixedColumnDef.DefaultView;
if (recordType != null && recordType.Length > 0) {
DataRelation relation = mapData.Tables["FixedParseDef"].ChildRelations[0];
if (relation != null) {
autoRelation = relation.RelationName;
childFilter = "Parent(" + autoRelation + ").recordType = '" + recordType +
"'";
}
}
view.RowFilter = childFilter;
--- "Woodard, John" <[EMAIL PROTECTED]> wrote:
> I am looking for a way to do an advanced query quickly and efficiently.
>
> Given the following XML structure read into a DataSet of people and the
> colors they are wearing:
>
> <Person>
> <Name>One</Name>
> <Color>Red</Color>
> <Color>Green</Color>
> <Color>Blue</Color>
> </Person>
> <Person>
> <Name>Two</Name>
> <Color>Red</Color>
> <Color>Green</Color>
> <Color>Orange</Color>
> </Person>
> <Person>
> <Name>Three</Name>
> <Color>Blue</Color>
> <Color>Green</Color>
> <Color>Orange</Color>
> </Person>
>
> Which would give me two related tables in my DataSet, Person and Color, and
> assume that there are tens of thousands of people in the table.
>
> How do I query for all people wearing red? It seems as if this should be
> possible, even simple, but I can't find a way to do it. Doing it row by row
> by using CreateChildView would take forever even on a screaming system.
> Querying the color table and then building a big honking query from the
> Person_id column (that ADO.NET puts in place to relate things in this
> circumstance) seems like it would be slow as well. How long would it take
> ADO to parse a search statement with 10,000 ORs? Ugh.