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

Moving from EntityFramework

3 Answers 83 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rayne
Top achievements
Rank 1
Rayne asked on 10 Nov 2011, 10:31 PM
I've got an application with a Data Library built on Entity Framework. I am looking into using OA instead for a number of reasons, but I think I need a little guidance.

My database consists of a many-many self referencing table. The join table has a triggers to create and delete the reciprocal records when changes are made to the relationships. Because it's a self-reference I don't need both sides as navigation properties. Can OA handle this? In EF, right now I have to have both nav properties, which I don't like.

I also have a one -> zero or one relationship. Both tables have the same primary key (Primary key is also foreign key to other table). In playing around, it didn't seem that I could define this relationship in OA. it interpreted it as a one -> many. Is this okay? Can I still use it this way and if so how will it work?

I'm not sure exactly how I use enums. Once I do a populate from database and create the enum, do I just change the data type and name of my property in the designer (so that the name isn't something like DivisionID)? Do I need to pull in the lookup table as well? Can these enums be used in linq queries?

EF doesn't have a way to undo changes without calling a refresh with storewins and it doens't work on many to many relationships, so I have to do a messy workaround. I saw in the docs that OA context can undo or revert changes. How does it do this? Does it do a fetch or does it actually keep track of the changes and revert them without fetching from database?

Can my collection properties only pull in a certain list? I'm running with lazy loading off so I'm eagerly loading collections. But in my database I have an IsDeleted flag that gets set from an instead of delete trigger. I'd prefer to just pull in those items by using a linq query such as Parent.Children.Load(c=>!c.IsDeleted). with EF I'm having to get everything, then use filters in my databinding to hide/collapse anything that has been deleted in the collection.

In the future I might consider putting this model in a Data Service. I've got concurrency properties that I'd prefer not to expose on the model, so I've marked them as private properties. As it is, the EF provider requires that all properties be public, so it doesn't work. Does the OA provider have the same restriction?

Thanks for answering all my questions.

3 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 15 Nov 2011, 12:05 PM
Hi Rayne,

Thank you for your interest in OpenAccess ORM.

First, let me pinpoint that we offer a wizard that automatically converts EF models to OpenAccess Domain Models. I think that it will be quite useful in your case.

To get to your question:
1) We offer two options for handling many-to-many relationships - you can map the join table as a separate Domain Class with two one-to-many relationships or you can simply use the navigational properties on both ends to express the relationship in your classes without having a class for the join table

2) One-to-one relationship is not directly supported, you can model such relations as one-to-many or as vertical inheritance between the classes, as described in the relevant Knowledge Base article.

3) Enum property types are supported by our Visual Designer and treated as the underlying value type by LINQ statements. You need to just create manually your enum and edit the selected property type in the designer.

4) When you make changes to the database through the OpenAccessContext, they are cached in memory and applied to the database when you call the SaveChanges() method. If you rollback the in-memory transaction by ClearChanges(), the database is not updated.

5) The navigation properties in OpenAccess ORM are fetched through lazy loading unless you specify explicitly that you want a collection to be loaded through Fetch Plans. However, filtering the collections while loading them for the first time is not supported. This means that you will either load the entire list of related objects or none of them.

6) Restricting the access to certain properties of OpenAccessContext exposed through a Data Service is possible with our product. If you need to configure such restriction, please revert back to us and we will explain in detail how to make the necessary changes.


I hope that information answers your questions. Do not hesitate to contact us for further details.

All the best,
Ivailo
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

0
Rayne
Top achievements
Rank 1
answered on 15 Nov 2011, 04:30 PM
Thank you for the feedback. Can I map an enum that has an underlying type of short to a database field of type smallint? I'm not actually trying to update my database schema but I did try to generate the script to see what it might have updated, but it doesn't like that my enum is a short. Does it only work on int enums?
0
Ivailo
Telerik team
answered on 18 Nov 2011, 01:26 PM
Hi Rayne,

Yes, defining enum type for a smallint field is allowed and usable.

In case you have any issue with doing that, send us a support ticket with your domain model, enum definition and database schema attached and we will advise you how to resolve it.

I am looking forward to your feedback.

All the best,
Ivailo
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

Tags
Design Time (Visual Designer & Tools)
Asked by
Rayne
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Rayne
Top achievements
Rank 1
Share this question
or