Solved

SQL Server and Embedded Data Classes

Posted on 2014-03-21
2
318 Views
Last Modified: 2014-03-22
I have a .Net C# application that uses data classes to manage data to\from database and UI's but for reporting over a WAN area network the stored proc calls back and forth to the database is causing a huge performance hit.

How can I use SQL Server to populated an Complex data class that has multiple embedded classes from the server without having to travel back to the client each time? See pseudo code examples below. When populating the Vendor class, for each Vendor, I have to find all of the Contracts and Projects for that Vendor in several SP calls. That's three separate calls. Is there a way to make one SP call to populate my Vendor Class?

Contract Class
{
      Int VendorID;
      Int ProjectID;
      Int ContractID;
      Decimal ContractAmt;
}

Project Class
{
      Int ProjectID;
      Int ProjectName;
      Date StartDate
      Date EndDate;
}


Vendor Class
{
      Int VendorID;
      string VendorName;
      ....
      String City;
      List<Contract> Contracts
      List<Project> Projects
}
0
Comment
Question by:csalerno
2 Comments
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 500 total points
ID: 39947285
Hi,

as SQL Server has powerful methods for that I would try to encode all the data into an XML structure and forward that as nvarchar(MAX) to the SP, you can also get a return structure on the same way and decode that in your frontend (I mainly use VBA as frontend and use the MSXML library to do that, I guess there are better ways using .NET code).

Cheers,

Christian
0
 

Author Closing Comment

by:csalerno
ID: 39947407
Yes, I have discovered sql servers XML PATH feature which looks like it would be a great fit for what I need. Thanks for confirming.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question