Running code as close to Data tier as possible

Running code as close to Data tier as possible

Old forum URL:

jpmir posted on Monday, November 28, 2011


Is there any possibility to know when the code is being executed in the nearest tier to Database Server???

I mean, in the same tier where Dataportal_Execute is being called...

There is some process in my application that needs to do several data operations over multiple objects and I'm trying to find a way to do them as close to Database server as possible to avoid network latency, iterative serialization and so on.

I've implemented a Command to execute this process, but as complex as it is, results in a very large awful unreadable object violating every single principle of OOP.

I would like to know to add methods to my business objects that only works in the DataAccess Layer... I'm thinking on some sort of condition like this:

Public Sub DoSomethingOnThisObject()

    If SomeMagicFormulaToKnowIfIamInDataLayer Then

       Calculate Data



        Throw New Exception("This method cannot be called directly")

    End if

End Sub


Please any advice is appreciated!



Marjon1 replied on Monday, November 28, 2011

As part of the ApplicationContext there is a property called ExecutionLocation that tells you if you are on the client, server or one silverlight.
There is also a LogicalExecutionLocation property, but I'm unsure as to difference between the two and I'm sure that ExecutionLocation worked for this previously.

So a simple check in your method to do something like this should work.

If ApplicationContext.ExecutionLocation = ApplicationContext.ExecutionLocations.Server Then 


jpmir replied on Monday, November 28, 2011

Hi Marjon1,

I'm leaving the office right now, I'll try your recommendation tomorrow.

Thank you very much!!!



JonnyBee replied on Tuesday, November 29, 2011

The distinction is as follows:

Using SimplePortal (ie: data access runs in-process on the Client),  when in DataPortal_XYZ or ObjectFactory you will have:
LogicalExecutionLocation = Server
ExecutionLocation = Client               (when running in .NET)
ExecutionLocation = Silverlight        (when running in Silverlight)

And when using any other portal (ie: N-tier) - and servercode will always run in .NET
LogicalExecutionLocation = Server
ExecutionLocation = Server

jpmir replied on Tuesday, November 29, 2011

Thanks guys for your suggestions, that's exactly what I needed to know.

According to JonnyBee, as my application will never run data access in-process, I'm taking ExecutionLocation for reference.


Thanks Again

Jean Paul

Copyright (c) Marimer LLC