locked
Correct way to retrieve data using asmx linked table RRS feed

  • Question

  • User-1526035670 posted
    I have a customer table which is related to an address table meaning they can have multiple addresses.

    I can retrieve the data for a list of customer and then create a POCO class to hold that data using my asmx web service (planning on moving to web API soon)

    Using an asmx service, if I retrieve a single customer, I would also like to retrieve their list of addresses. One way I think I can do this (again via an asmx service) is to load the customer using the id and then get the records using that id when the page is accessed. Is there a better way to do this or would it have to be 2 calls as in 1 for the customer record on page access then the second for the list of addresses returned by the id of the customer?
    Friday, April 3, 2020 9:12 PM

All replies

  • User475983607 posted

    Using an asmx service, if I retrieve a single customer, I would also like to retrieve their list of addresses. One way I think I can do this (again via an asmx service) is to load the customer using the id and then get the records using that id when the page is accessed. Is there a better way to do this or would it have to be 2 calls as in 1 for the customer record on page access then the second for the list of addresses returned by the id of the customer?

    This is totally dependent on your data access layer which is unknown   In LINQ to Entities it's a projection query.  In ADO.NET two queries will work or return a dataset with two tables then populate the POCOs.

    Friday, April 3, 2020 9:52 PM
  • User-1526035670 posted
    Hi Mge

    I have a DBML file for for my data layer. I then have a separate project for business layer where data is called using Linq to SQL. So based on your answer 2 queries should be ok but I'm interested in learning other ways so was reading this article

    https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/query-expression-syntax-examples-projection-linq-to-dataset

    In which case could/should I have a dataset with two tables assigned and then query or it or am I just adding more complexity than necessary?
    Saturday, April 4, 2020 3:36 AM
  • User-719153870 posted

    Hi JamieP1,

    In which case could/should I have a dataset with two tables assigned and then query or it or am I just adding more complexity than necessary?

    Whether it's adding more complexity than necessary depends on how you are gonna deal with the usement. For more information about in which case you shall use the dataset, please check the dataset doc.

    Best Regard,

    Yang Shen

    Monday, April 6, 2020 9:16 AM