Is LINQ to SQL server-side execution ?

Is LINQ to SQL server-side execution ?

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


Hurty posted on Friday, January 27, 2012

Hello everyone.

For couple of months I've been working with CSLA framework and I've been very positive about all the features. They are just great. However, I ran into making the whole application currently working on being 3-tier application. So I created WCF data portal and put the logic server-side except...

...except local LINQ to SQL logic.

So here is the question:
Are LINQ to SQL executing actions server-side or only local-side.

Here is snippet from what I use:

 using (var ctx = ContextManager<LoginDataDataContext>.GetManager(Database.LoginData))

Will using the context trigger the actions on the server or will they remain on local machine ?

George.

richardb replied on Friday, January 27, 2012

If this code is in your DataPortal_xxx methods then it would run in the location where the Data portal is configured, in this case in your WCF data portal on the server.

 

JonnyBee replied on Friday, January 27, 2012

Hi,

If your app is to be a true 3-tier application then all data access (including Linq2SQL) must happen on the serverside.

Hurty replied on Sunday, January 29, 2012

Thanks guys... but if my LINQ2SQL code (posted above) it not included in DataPortal_ZYZ() methos would that code still run on server or will be local only?

JonnyBee replied on Sunday, January 29, 2012

Only code in DataPortal_XYZ  or Objectfactories or called from within these methods are executed on the server.

IE: All code is cleintSide code except for code that is called by:

from the client. The DataPortal will add context information and depending on configuration send the object to the server and call the method on the server.

For more detailed information I recommend the Using CSLA 4 ebooks from Rocky.

 

Hurty replied on Monday, January 30, 2012

Thank you for the answer. Have the books from Lhotka, but haven't met anything about remote LINQ. And as you've said I should move my LINQ2SQL code to DataPortal.SOMETHING() to execute on the server.

A lot of thanks for the clearness.

George.

Copyright (c) Marimer LLC