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

Get Context form ObjectScope

1 Answer 54 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wolfgang
Top achievements
Rank 1
Wolfgang asked on 23 Jan 2014, 01:01 PM
Hi,

Using classic ObjectScope I have the following problem.

At some point
MetaPersistentType.CreateEntityInstance()
is used. According to documentation it is obsolete and CreateEntityInstance(context) should be used instead. But how is it possible to get a OpenAccessContextBase from ObjectScope? Best regards Wolfgang

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 24 Jan 2014, 02:34 PM
Hello Wolfgang,

 You cannot get an OpenAccessContextBase from an ObjectScope. Both are wrappers around a lower layer object. But what you can do is use the following code to create an instance of a type.

var persistentTypeDescriptor = scope.PersistentMetaData.GetPersistentTypeDescriptor(typename);
var instance = persistentTypeDescriptor.CreateInstance(idValue);

If the id value is backend calculated you can pass a 'null' value.
The above code essentially does the same thing as MetaPersistentType.CreateEntityInstance.

Regards,
Ady
Telerik
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features shipped with our latest release!
Tags
Development (API, general questions)
Asked by
Wolfgang
Top achievements
Rank 1
Answers by
Ady
Telerik team
Share this question
or