SELECT data from DataSet tables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RnJhbmsgVXJheQ==?=

    SELECT data from DataSet tables

    Hi all

    I have a DataSet with 2 tables.
    Now I want to select data like a INNER JOIN from these tables.

    In SQL Syntax I would write:
    SELECT *
    FROM table1 t1
    INNER JOIN table2 t2
    ON t1.f1 = t2.f1
    WHERE t2.xy = 'search'

    How do I select data like this from a DataSet ??
    Or how else can I select data from a DataSet
    when I want to get a combination of two or
    more tables ??

    Thanks for any comments

    Best regards
    Frank
  • Marc Gravell

    #2
    Re: SELECT data from DataSet tables

    Well, in .NET 3.5 you could probably use LINQ-to-objects to do this as a
    join directly, but it looks like you should really be looking via the
    DataRelations, where you have a DataRelation linking the two "f1"s. Then
    you can use GetParentRow(re lation) or GetChildRows(re lation) to do the
    navigation.

    Does that help at all?

    Marc

    Comment

    • =?Utf-8?B?RnJhbmsgVXJheQ==?=

      #3
      Re: SELECT data from DataSet tables

      Hi Marc

      Thanks for your answer.

      I will have to try with GetParentRow/GetChildRow
      I did never try with this.

      But I ab wondering how other people work with
      complex data structures in Datasets ...

      Best regards
      Frank

      "Marc Gravell" wrote:
      Well, in .NET 3.5 you could probably use LINQ-to-objects to do this as a
      join directly, but it looks like you should really be looking via the
      DataRelations, where you have a DataRelation linking the two "f1"s. Then
      you can use GetParentRow(re lation) or GetChildRows(re lation) to do the
      navigation.
      >
      Does that help at all?
      >
      Marc
      >

      Comment

      • Marc Gravell

        #4
        Re: SELECT data from DataSet tables

        I've wondered that myself ;-p

        (I'm not a big user of datasets, so I can't answer it, I'm afraid)

        Marc

        Comment

        • =?Utf-8?B?RnJhbmsgVXJheQ==?=

          #5
          Re: SELECT data from DataSet tables

          :-)))

          Me too, I used to build online apps with
          DataReader's.
          But now I have to build a application with
          offline (xml file) modus ...

          Thanks anyway
          Frank



          "Marc Gravell" wrote:
          I've wondered that myself ;-p
          >
          (I'm not a big user of datasets, so I can't answer it, I'm afraid)
          >
          Marc
          >

          Comment

          • Tim Jarvis

            #6
            Re: SELECT data from DataSet tables

            Frank Uray wrote:
            Me too, I used to build online apps with
            DataReader's.
            But now I have to build a application with
            offline (xml file) modus ...
            Hi Frank,

            If you have the option, push very hard to be able to use Linq for
            DataSets (.NET 3.5) I guarantee that you will never want to navigate
            datasets (or for that matter raw XML) any other way...

            DataTable orders = ds.Tables["SalesOrderHead er"];
            DataTable orderLines = ds.Tables["SalesOrderDeta il"];

            var ordersQuery = orders.AsEnumer able();
            var orderLinesQuery = orderLines.AsEn umerable();

            var query = from o in ordersQuery
            join ol in orderLinesQuery
            on o.Field<int>("S alesOrderID") equals
            ol.Field<int>(" SalesOrderID")
            where o.Field<bool>(" OnlineOrderFlag ") == true &&
            o.Field<DateTim e>("OrderDate") .Month == 8
            select new { SalesOrderID = o.Field<int>("S alesOrderID"),
            SalesOrderDetai lID =
            ol.Field<int>(" SalesOrderDetai lID"),
            OrderDate = o.Field<DateTim e>("OrderDate") ,
            ProductID = ol.Field<int>(" ProductID") };


            Cheers Tim.

            --

            Comment

            Working...