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

OpenAccess x EF 4

4 Answers 66 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 27 Dec 2011, 01:14 AM
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

4 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 28 Dec 2011, 05:00 PM
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. 
0
Alex
Top achievements
Rank 1
answered on 28 Dec 2011, 05:24 PM
(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()


0
Zoran
Telerik team
answered on 29 Dec 2011, 05:30 PM
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. 
0
Alex
Top achievements
Rank 1
answered on 29 Dec 2011, 05:50 PM
I will try it.
Tags
Data Access Free Edition
Asked by
Alex
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Alex
Top achievements
Rank 1
Share this question
or