none
search in typed dataset RRS feed

  • Question

  • Hi I have a typed dataset with multi datatables. now my question:
    Which way is the best to find a row in a datatable?
    I have thousands rows in dataset datatables and i'm looking for a search method which use less memory. i.e do you think which one is the best:
    - use table adapter to fill datatable and then create new dataview based on it.
    - use select method of datatable(without fill by tableadapter if possible?).
    - create a new query in dataset design view to find a row with given parameter(s).
    Thanks.
    • Edited by Mehdi0016 Thursday, November 3, 2011 4:10 PM
    Thursday, November 3, 2011 4:04 PM

Answers

  • There is no best way. Ways are invented because of previous ways don't fit the particular project's requirement. Sometimes mixing ways is needed to balance development time vs runtime performance.

    The article Best Practices for Using ADO.NET lists some factors in choosing data access methods. However best practices is a subjective term, expect rules to be broken in development.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Thursday, November 3, 2011 4:28 PM
  • Hi Mehdi0016,

        There are many ways can query the record, ado.net or linq, linq is more easy to write. How to write the query statement, it depends on your table's structure. If you have a List<Customers> and a List<Orders>, the Customers class have a orderId property and the Orders class have a price property, you can write the linq like this:

    var cus = from c in cusList join o in orderList on c.orderId equals o.id where o.price > 99.00 select c;

     

    You can also use ado.net to do that, it needs more lines code but it's more efficient.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 8, 2011 3:33 AM
    Moderator

All replies

  • There is no best way. Ways are invented because of previous ways don't fit the particular project's requirement. Sometimes mixing ways is needed to balance development time vs runtime performance.

    The article Best Practices for Using ADO.NET lists some factors in choosing data access methods. However best practices is a subjective term, expect rules to be broken in development.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Thursday, November 3, 2011 4:28 PM
  • Thanks for reply. But i still have problem with cross table query within typed dataset. i.e. select customer which have orders with price greater than 99$. I'm not sure how to do this?
    Sunday, November 6, 2011 2:46 PM
  • all 3 methods mentioned in your original post should be able to do this, Linq could make writing the query easier but is not necessary. 

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Sunday, November 6, 2011 3:35 PM
  • Hi Mehdi0016,

        There are many ways can query the record, ado.net or linq, linq is more easy to write. How to write the query statement, it depends on your table's structure. If you have a List<Customers> and a List<Orders>, the Customers class have a orderId property and the Orders class have a price property, you can write the linq like this:

    var cus = from c in cusList join o in orderList on c.orderId equals o.id where o.price > 99.00 select c;

     

    You can also use ado.net to do that, it needs more lines code but it's more efficient.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 8, 2011 3:33 AM
    Moderator