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

qury result from context schema to container ?

1 Answer 37 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marchand
Top achievements
Rank 1
Marchand asked on 24 Nov 2010, 03:34 PM
Hi,

i just want to know how can I do to add the result of OQL result to a caontainer (with disconned mode) ?

Example of code with scope object :
==> but I want to use context database .... How can I  do ?
In advance, thanks....

 ObjectContainer.ChangeSet ccData = null;
                IObjectScope os = ISSYS_Qualification_BO.ObjectScopeProvider.GetNewObjectScope();


             
                os.Transaction.Begin();
                try
                {
                    string resultName = "User";
                    string query = "from u in this.Context.Users select u";
                    IQuery qry = os.GetOqlQuery(query);
                    IQueryResult qres = qry.Execute();



                    ObjectContainer oc = new ObjectContainer();

                    // default deep
                    Telerik.OpenAccess.IObjectCollector objCollector =
                        new FetchGroupCollector(FetchGroupCollector.DefaultFetchGroup);

                    if (qres != null)
                    {
                        try
                        {
                            int cnt = qres.Count;
                            oc.CopyFrom(os, resultName, qres, objCollector);
                        }
                        catch (Exception exc)
                        {
                            string msg = exc.Message;
                            oc.CopyFrom(os, resultName, qres, null);
                        }
                    }
                    else
                        oc.CopyFrom(os, resultName, qres, null);

                    ccData = oc.GetContent();
                }
                finally
                {
                    os.Transaction.Rollback();
                    os.Dispose();
                }
                return ccData;


1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 26 Nov 2010, 06:27 PM
Hello Marchand,

You can gain access to an internal scope related to the OpenAccessContext by extending the definition of the partial class where the derived context resides.
public partial class NorthwindEntityDiagrams : OpenAccessContext
{
    public IObjectScope GetInternalScope()
    {
        return this.GetScope();
    }
}
The OQL API is supported only with the scope approach. I hope this is what you are looking for.

Do not hesitate to contact us to discuss anything that you find important.

Greetings,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
Getting Started
Asked by
Marchand
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or