OpenAccess x EF 4

5 posts, 0 answers
  1. Alex
    Alex avatar
    9 posts
    Member since:
    Sep 2008

    Posted 26 Dec 2011 Link to this post

    Hi Guys,

    I'm currently think to migrate my EF 4.1 project to OpenAccess, but before it I have many questions :

    (1) In EF I can track changes (tables and Fields) very easy but in your Demos it is very complex. Do you have a more easy example ?
    (2) OpenAccess work equals for all supported databases without code changes ? I need to support SQLServer and SQLite;
    (3) Does OpenAccess support eSQL or similar feature ?
    (4) How to write event like "SavingChages" to validate objects before post ? 
    (5) Does OpenAccess support Enum fields like EF 4.1 June CTP ?

    Regards,
    Alexnaldo Santos
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 28 Dec 2011 Link to this post

    Hello Alex,

    First of all, we are happy to know about your interest in our project. Now lets proceed to your questions:

     1) Can you give us more information about what you understand by tracking the changes of fields and tables? Do you have database migration in mind(for example changing the database and trying to update the domain model out of this). Or, do you have in mind listening to events similar to OnPropertyChanged()? Both are possible with OpenAccess but we have to find the right case to present it to you.

     2) Yes, that is a feature of our product.

     3) No, OpenAccess works with Linq as a .NET standard for querying data. It also exposes API for executing direct SQL to your database server.

     4) This is possible by implementing IInstanceCallbacks on your objects.

     5) OpenAccess natively supports enum fields. You should just manually set the type of your field to be your custom enum in the Visual Designer(there is no such UI integration for supporting enums as it is in EF at the moment). However OpenAccess can work with any enum, not only enums that are created via a special UI as it is with EF.

    Kind regards,
    Zoran
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  3. DevCraft banner
  4. Alex
    Alex avatar
    9 posts
    Member since:
    Sep 2008

    Posted 28 Dec 2011 Link to this post

    (1)  I see in your demo (TrackingChanges) code like it :

    if( theObjectScopeProvider1 == null )
        theObjectScopeProvider1 = new SampleDBProvider();
     
    if( theObjectScopeProvider1.myDatabase == null )
    {
        string assumedInitialConfiguration =
                   "<openaccess>" +
                       "<references>" +
                           "<reference assemblyname='PLACEHOLDER' configrequired='True'/>" +
                       "</references>" +
                   "</openaccess>";
        System.Reflection.Assembly dll = theObjectScopeProvider1.GetType().Assembly;
        assumedInitialConfiguration = assumedInitialConfiguration.Replace(
                                            "PLACEHOLDER", dll.GetName().Name);
        System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        xmlDoc.LoadXml(assumedInitialConfiguration);
        Database db = Telerik.OpenAccess.Database.Get("SampleDBConnection",
                                    xmlDoc.DocumentElement,
                                    new System.Reflection.Assembly[] { dll } );
     
        theObjectScopeProvider1.myDatabase = db;
    }


    (2) I din't see any example about your InstanceCallbacks . Do I need to implement it for 300 entities ?


    For EF I only need one  "override" for SaveChanges()


  5. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 29 Dec 2011 Link to this post

    Hello Alex,

    As for the track changes code, this is an obsolete code and is not related to this feature. However what you need to do is to create a partial class to your context class and expose an IObjectScope object:
    public partial EntityDiagramsContext
    {
       public IObjectScope Scope
       {
           get{return this.GetScope();}
       }
    }

    Then you should attach to the tracking events as follows:
    EntityDiagramsContext context = new EntityDiagramsContext();
    IObjectScope scope = context.Scope;
    scope.Tracking.Added += new AddEventHandler(Tracking_Added);
     
     
     void Tracking_Added(object sender, AddEventArgs e)
     {
             //your tracking code here;
     }


     
    As for the IInstanceCallbacks, there is no way to apply that automatically to all entities. This is a nice feature request though and we will put a goal on our TODO list to make this process more transparent.

    Greetings,
    Zoran
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  6. Alex
    Alex avatar
    9 posts
    Member since:
    Sep 2008

    Posted 29 Dec 2011 Link to this post

    I will try it.
Back to Top
DevCraft banner