CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

LINQ To SQL in PTracker

Last post 05-19-2008, 4:41 PM by RockfordLhotka. 2 replies.
Sort Posts: Previous Next
  •  05-18-2008, 9:32 PM 23642

    LINQ To SQL in PTracker

    Rocky,

    I've noticed that there are stored procedures writen and availalbe in the PTRACKER database but in the business objects, instead of calling the stored procedure method in the DataContext, LINQ to SQL is used.

    For example: In the DataPortal_Fetch method of the Project business object the code could use the following to call the stored proc available

    ctx.DataContext.getProject(criteria).Single();

    Instead of

    var data = (from p in ctx.DataContext.Projects
    where p.Id == criteria.Value
    select p).Single();

     

    Why have the stored procs if you're not going to use them? Maybe I'm missing something here...

     

    Thanks,

    CKA

     

     

  •  05-19-2008, 2:55 AM 23644 in reply to 23642

    Re: LINQ To SQL in PTracker

    Rocky does use the stored procedures in the insert, update and delete operations. I guess he just wanted to illustrate how to use both in LINQ.

    Philip

  •  05-19-2008, 4:41 PM 23674 in reply to 23644

    Re: LINQ To SQL in PTracker

    That is true, I did want to show different techniques.

    However, it is also the case that using the existing sprocs to get data is problematic. This is because the pre-existing getXYZ sprocs often return multiple result sets.

    L2S can handle multiple result sets - but the designer in Visual Studio 2008 can't. In other words, you have to either use the external sqlmetal tool or hand-craft your L2S code to get multiple result sets from a sproc. I wanted to stick with the built-in VS designer, and that imposes the limitation.


    Rocky
View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems