Persistence of byte array using WCF RIA

2 posts, 0 answers
  1. Ian
    Ian avatar
    4 posts
    Member since:
    Mar 2009

    Posted 28 Sep 2010 Link to this post

    Hi

    I'm trying to persist a byte array (layout data from Silverlight RadDocking) using OpenAccess and WCF RIA generated using the Domain Service Wizard.  I get the warning as explained here (http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-explicit-change-tracking.html) but have no idea of how to handle this in the context of RIA. 

    Any guidance gratefully appreciated.

    Thanks

    Ian
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 01 Oct 2010 Link to this post

    Hi Ian,

     You can expose the IObjectScope from your context class. So for example imagine that this is your context class:

    public partial class NorthwindEntityDiagrams : OpenAccessContext
        {
            private static string connectionStringName = "NorthwindEntityDiagrams";
                 
            private static BackendConfiguration backend = GetBackendConfiguration();
             
                 
            private static MetadataSource metadataSource = XmlMetadataSource.FromAssemblyResource("EntityDiagrams.rlinq");
         
            public NorthwindEntityDiagrams()
                :base(connectionStringName, backend, metadataSource)
            { }
             
            public NorthwindEntityDiagrams(string connection)
                :base(connection, backend, metadataSource)
            { }
         
            public NorthwindEntityDiagrams(BackendConfiguration backendConfiguration)
                :base(connectionStringName, backendConfiguration, metadataSource)
            { }
                 
            public NorthwindEntityDiagrams(string connection, MetadataSource metadataSource)
                :base(connection, backend, metadataSource)
            { }
             
            public NorthwindEntityDiagrams(string connection, BackendConfiguration backendConfiguration, MetadataSource metadataSource)
                :base(connection, backendConfiguration, metadataSource)
            { }
                 
            public IQueryable<Category> Categories
            {
                get
                {
                    return this.GetAll<Category>();
                }
            }      
             
            public static BackendConfiguration GetBackendConfiguration()
            {
                BackendConfiguration backend = new BackendConfiguration();
                backend.Backend = "mssql";
                return backend;
            }
     
            public IObjectScope GetObjectScope
            {
                get
                {
                    return this.GetScope();
                }
            }
        }
    The highlighted code is the one I have added. Having the scope exposed you can add the following method to your RIA data service:
    public void MarkPictureAsChanged(Category category)
           {
               this.DataContext.GetObjectScope.MakeDirty(category, "Picture");           
           }
    I hope this helps.


    Kind regards,
    Petar
    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
  3. DevCraft banner
Back to Top