This is a migrated thread and some comments may be shown as answers.

[Solved] Getting the scope from inside an object

7 Answers 170 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
sitefinitysteve asked on 04 Oct 2010, 03:49 PM
If I have a partial class extending one of my legacy Reverse Mapped objects (ie not mapped with rlinq)...can I somehow get a reference to the CURRENT scope?

So for example if this is the partial class property I made
public bool IsCompleted {
            get {
                bool isComplete = true;
 
                //Get the max level which denotes complete
                var maxChainID = this.GetApprovalChain().OrderByDescending(x => x.ApproverLevel).Single().ApproverLevel;
 
                //Check that maxChainID against the top approval
                if (this.Approvals.OrderByDescending(x => x.ApprovalChainLevel).Single().ApprovalChainLevel < maxChainID)
                    isComplete = false;
 
                //Check Approvals for any Pendings (should catch parallels)
                foreach (RTODataLayer.Approval approval in this.Approvals) {
                    if (approval.StatusID == 1) {
                        isComplete = false;
                    }
                }
 
                return isComplete;
            }
        }

Is there some way to get a reference to the scope which created this so I could query another object without having to create another IObjectScope.

Does that make sense?

Steve

7 Answers, 1 is accepted

Sort by
0
Accepted
IT-Als
Top achievements
Rank 1
answered on 05 Oct 2010, 05:49 AM
Hi Steve,

Within a persistent object, you can do this:

IObjectScope scope = Database.GetContext(this) as IObjectScope;

to get the ObjectScope for the instance passed in as argument to GetContext method.

Regards

Henrik
0
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 05 Oct 2010, 01:37 PM
Any idea how this would work in an rLinq Context?  I think it's just a wrapped IObjectScope, but I don't see those objects\methods available to me.
0
IT-Als
Top achievements
Rank 1
answered on 06 Oct 2010, 08:31 AM
Hi Steve,

Sorry, I don't what the Context equivalent would be.. Maybe you can just cast it to your OpenAccessContext (if it implements IObjectContext).
Can anyone from Telerik elaborate on this?

Regards

Henrik
0
Damyan Bogoev
Telerik team
answered on 06 Oct 2010, 06:29 PM
Hi Henrik,

Currently there is no way to obtain the OpenAccessContext that manages a persistent capable object like for the IObjectScope. I am sorry for the inconvenience caused.

Regards,
Damyan Bogoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 06 Oct 2010, 06:30 PM
Oh really!

Hmmm, could that be exposed in a future update? (PITS)?
0
Damyan Bogoev
Telerik team
answered on 11 Oct 2010, 05:46 PM
Hi Steve,

We will do our best to implement this feature for the Q3 release which is scheduled for the middle of November.

Best wishes,
Damyan Bogoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 11 Oct 2010, 05:52 PM
Fantastic! Thank you
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
IT-Als
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Iron
Iron
Veteran
Damyan Bogoev
Telerik team
Share this question
or