LINQ To SQL in PTracker

LINQ To SQL in PTracker

Old forum URL: forums.lhotka.net/forums/t/4860.aspx


ForteUnited posted on Sunday, May 18, 2008

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

 

 

Philip replied on Monday, May 19, 2008

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

RockfordLhotka replied on Monday, May 19, 2008

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.

Copyright (c) Marimer LLC