Get Context form ObjectScope

Thread is closed for posting
2 posts, 0 answers
  1. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 23 Jan 2014 Link to this post


    Using classic ObjectScope I have the following problem.

    At some point
    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
  2. Ady
    Ady avatar
    589 posts

    Posted 24 Jan 2014 Link to this post

    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.

    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!
Back to Top