CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Running code as close to Data tier as possible

    rated by 0 users
    Answered (Verified) This post has 2 verified answers | 4 Replies | 1 Follower

    Top 500 Contributor
    25 Posts
    jpmir posted on Mon, Nov 28 2011 3:06 PM

    Hi,

    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
            ReadData

           Calculate Data

            WriteData

        Else

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

        End if

    End Sub

     

    Please any advice is appreciated!

    Regards

    JP

    Answered (Verified) Verified Answer

    Top 50 Contributor
    161 Posts
    Verified by jpmir

    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 

     

    Don't forget to verify the post(s) that best answers your question!

    .NET Developer @ http://www.sybiz.com.au

    Top 10 Contributor
    2,279 Posts
    Answered (Verified) JonnyBee replied on Tue, Nov 29 2011 12:09 AM
    Verified by jpmir

    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

    Jonny Bekkum, Norway CslaContrib Coordinator

    All Replies

    Top 50 Contributor
    161 Posts
    Verified by jpmir

    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 

     

    Don't forget to verify the post(s) that best answers your question!

    .NET Developer @ http://www.sybiz.com.au

    Top 500 Contributor
    25 Posts
    jpmir replied on Mon, Nov 28 2011 5:17 PM

    Hi Marjon1,

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

    Thank you very much!!!

     

     

    Top 10 Contributor
    2,279 Posts
    Answered (Verified) JonnyBee replied on Tue, Nov 29 2011 12:09 AM
    Verified by jpmir

    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

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 500 Contributor
    25 Posts
    jpmir replied on Tue, Nov 29 2011 9:10 AM

    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

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems