Custom response from dataset

Discussion in 'ASP .Net Web Services' started by nano2k, Feb 6, 2007.

  1. nano2k

    nano2k Guest

    Hi
    I'm facing a performance issue with my webservice.
    I have a webmethod that returns the result of an sql query. I use an
    SqlDataAdapter object that fills an DataSet object with my results. My
    problem is that I need to alter a bit my results. For each record I
    need to append some new data. So, my current implementation builds a
    new XmlDocument which will be filled step by step while looping
    through dataset rows and appending my custom info. Finally, the xml
    document is sent as the response to the calling client application.
    The problem is that using this method allows me to append any
    information I need, but the cost is sometimes too big (processing
    power + memory) because my method practically doubles the memory
    needed for the response to be sent: first, the dataset allocates,
    let's say, 10MB, then, I reallocate 10MB (plus 1MB of custom data) to
    build my custom response. So, at one moment in processing, my method
    allocates 20+ MB.
    To avoid this, I think the best way is to alter the dataset itself by
    attaching new attributes to each element that represents a record.
    Is there a way to access and modify this intimate XML representation
    of a dataset?

    Thanks.
     
    nano2k, Feb 6, 2007
    #1
    1. Advertising

  2. "nano2k" <> wrote in message
    news:...
    > Hi
    > I'm facing a performance issue with my webservice.
    > I have a webmethod that returns the result of an sql query. I use an
    > SqlDataAdapter object that fills an DataSet object with my results. My
    > problem is that I need to alter a bit my results. For each record I
    > need to append some new data. So, my current implementation builds a
    > new XmlDocument which will be filled step by step while looping
    > through dataset rows and appending my custom info. Finally, the xml
    > document is sent as the response to the calling client application.
    > The problem is that using this method allows me to append any
    > information I need, but the cost is sometimes too big (processing
    > power + memory) because my method practically doubles the memory
    > needed for the response to be sent: first, the dataset allocates,
    > let's say, 10MB, then, I reallocate 10MB (plus 1MB of custom data) to
    > build my custom response. So, at one moment in processing, my method
    > allocates 20+ MB.
    > To avoid this, I think the best way is to alter the dataset itself by
    > attaching new attributes to each element that represents a record.
    > Is there a way to access and modify this intimate XML representation
    > of a dataset?


    You don't have to get intimate with the DataSet in order to accomplish this.
    You can add columns to the dataset. For instance,

    ds.Tables[0].Columns.Add("newColumn1", typeof(string));

    You can even create expression columns if some of your columns can be
    computed from the values of other columns.

    John
     
    John Saunders, Feb 7, 2007
    #2
    1. Advertising

  3. nano2k

    nano2k Guest

    Thanks for your response.
    For some (good) reasons I need to append some extra data to each
    column (like: it's type, and some other computed info, but only for
    some specific types of columns). I used to use xml attributes to pass
    this kind of info, like this:

    <punitid shortDescription="buc" type="guid" someData="someDataValue"
    etc>65a13829-2fca-4cc6-ab1f-4f979364a6f5</punitid>

    Unfortunately, not all data can be added only by adding extra computed
    columns to my dataset (well, datatables).
    I found out that the easiest way is to use an XmlDataDocument object
    and to pass my dataset to it's constructor.
    It seems that no significant overhead is generated by this operation.
    Then, I'm able to process each row node and to add as many xml
    attributes I want by using plain XmlDocument actions.
    My only concern is that I read some posts about XmlDataDocument that
    report some troubles using this class. Specifically, the class's
    performance drops when used intensely (it's also my case). Ok, the
    posts were pretty old, but it seems that this issue was reported to
    microsoft as a bug.
    Does anybody have update info regarding this? Btw: I'm using v1.1.4322
    of .net framework.
    Thanks.


    John Saunders a scris:
    > "nano2k" <> wrote in message
    > news:...
    > > Hi
    > > I'm facing a performance issue with my webservice.
    > > I have a webmethod that returns the result of an sql query. I use an
    > > SqlDataAdapter object that fills an DataSet object with my results. My
    > > problem is that I need to alter a bit my results. For each record I
    > > need to append some new data. So, my current implementation builds a
    > > new XmlDocument which will be filled step by step while looping
    > > through dataset rows and appending my custom info. Finally, the xml
    > > document is sent as the response to the calling client application.
    > > The problem is that using this method allows me to append any
    > > information I need, but the cost is sometimes too big (processing
    > > power + memory) because my method practically doubles the memory
    > > needed for the response to be sent: first, the dataset allocates,
    > > let's say, 10MB, then, I reallocate 10MB (plus 1MB of custom data) to
    > > build my custom response. So, at one moment in processing, my method
    > > allocates 20+ MB.
    > > To avoid this, I think the best way is to alter the dataset itself by
    > > attaching new attributes to each element that represents a record.
    > > Is there a way to access and modify this intimate XML representation
    > > of a dataset?

    >
    > You don't have to get intimate with the DataSet in order to accomplish this.
    > You can add columns to the dataset. For instance,
    >
    > ds.Tables[0].Columns.Add("newColumn1", typeof(string));
    >
    > You can even create expression columns if some of your columns can be
    > computed from the values of other columns.
    >
    > John
     
    nano2k, Feb 7, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,820
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    535
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    410
  4. Nedu N
    Replies:
    2
    Views:
    2,176
  5. William Gower
    Replies:
    2
    Views:
    4,162
    Brian Baker [MVP]
    Jul 26, 2004
Loading...

Share This Page