Solved

SQL Server and Embedded Data Classes

Posted on 2014-03-21
2
309 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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now