Print Page | Close Window

Is it possible to create Class of ORM at run time at client side?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2020
Printed Date: 21-Apr-2026 at 8:39pm


Topic: Is it possible to create Class of ORM at run time at client side?
Posted By: Thinkly
Subject: Is it possible to create Class of ORM at run time at client side?
Date Posted: 27-Jul-2010 at 11:32pm
I am new to DevForce. Actually I am new to Entity Framework also.

I am using other ORM solution, which has nothing to do with Entity Framework. With its schema API, I can create class of ORM at run time at client side. For example, I may create a class of Models with a relationship with existing class Product. Each model belongs to one Product.

I searched this website and I couldn't find such a kind of API to do so.

I am wondering whether it is possible to do so.

My application highly depends on such a function. And I am thinking to immigrate my application to DevForce.

Please give me some hints.

Thank you in advance,

Ying



Replies:
Posted By: ting
Date Posted: 28-Jul-2010 at 4:19pm
The Entity Framework (and by extension DevForce) does not currently support mapping a table discovered at runtime to a class.  You can accomplish this with the POCO support in DevForce, but I don't know if that will meet your need.  You can read about POCO here:
http://www.ideablade.com:8989/xwiki/bin/view/Documentation/POCOSupportInDevForce - http://www.ideablade.com:8989/xwiki/bin/view/Documentation/POCOSupportInDevForce
 


Posted By: Thinkly
Date Posted: 28-Jul-2010 at 7:58pm
In your mentioned document, it is said “The class for your object must be deployed on both the client and ***the server*** and must be contained in one of the assemblies routinely searched by DevForce.”

It seems I can only create a static class object, instead of a dynamic class object. In other words, end user cannot create a dynamic class, which is not pre-defined at compiling period, at run time.

If so, I will evaluate DevForce later.

IdeaBlade is appreciated to confirm.


Thank you,

Ying


Posted By: ting
Date Posted: 29-Jul-2010 at 8:32pm
The only requirements for the POCO are:
1)  The object must have a key.
2)  The object must be serializable by WCF.
3)  The POCO Service Provider class you write must return an IEnumerable<T>.
 
Provided you know how to dynamically construct the class definition on the client and server, this should work.
 
Since a dynamic class is essentially used like a map / property bag / dictionary, you may find it easier to define a static POCO type that contains the key-value pairs. This simplifies the type construction, but still gives you access to all the runtime defined data.
 
If this is a large part of your application, I'm not sure if DevForce is a good fit for you though.
 


Posted By: Thinkly
Date Posted: 29-Jul-2010 at 10:45pm
You mentioned "Provided you know how to dynamically construct the class definition on the client and server, this should work.". Yes, I know how to do it. So it seems I could find a solution.

You mentioned "If this is a large part of your application, I'm not sure if DevForce is a good fit for you though.". Yes, it is a large part of my application. I am sorry to know maybe DevForce is not a good fit.

I think my requirement is very common. For every application has to provide customization for end users, especially custom fields(columns) to existing tables(classes). Actually some XPO frameworks provide such a kind of functions. The reason I try to switch to DevForce is for richer functions, such as N-tier and security modules.


For the requirement of customization is common, why doesn't DevForce show a solution?


Thanks,

Ying




Posted By: ting
Date Posted: 30-Jul-2010 at 5:42pm
We actually provided this functionality in our DevForce Classic product.  We lost this when moving to the Entity Framework because Microsoft does not support it.  We are looking at a feature which would allow runtime type definition in the Entity Framework, but that is still a ways off.
 
There are also other schema structures that can approximate user-defined fields, but as you know they all have side effects and tradeoffs.
 


Posted By: Thinkly
Date Posted: 01-Aug-2010 at 10:29pm
I have a new idea.

1. Use a stored procedure to add custom columns and tables.

2. Generate new EF classes on the fly on the server side and "copy" it to the client side by a special method, such as a BLOB field.

3. Load the new EF classes at both server side and client side. The new classes will override the old ones according to their attributes, such as "table name".

Of course, this is a vary basic idea. Just for your information.


Good luck.

Ying



Print Page | Close Window