New Posts New Posts RSS Feed: Model Extension via MEF
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Model Extension via MEF

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: Model Extension via MEF
    Posted: 02-Apr-2012 at 1:36am
Hi,

Assuming I have a project named Domain where my Model resides that has 1 Entity with a definition as follows:

MyEntity
- ID (int)
- MyDescription (string)
- MyOtherField (datetime)

I have a Business Rule Project that is accessing my Domain project.

What I'm trying to do is to have a "customized" Domain project that has the same Model and Entity but with additional fields such as:

MyEntity
- ID (int)
- MyDescription (string)
- MyOtherField (datetime)
- MyCustomOtherField (string)

Now what I want to accomplished is that, I don't want to rewrite my whole Business Rule project to use the customized Domain project but instead use MEF or any other technique to just simply plug and play this customization.

What is the best way to do it in Devforce?

Thanks,
Von

Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2012 at 1:38am
Note: By not using Code First approach here..
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2012 at 3:50pm
Hi Vonzkie,

If I understand correctly, it seems that you want to add a custom property to your existing Entity classes. Each Entity class generated by DevForce is a partial class. So you can extend it however you want by simply declaring another partial class of the same Entity.

Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 02-Apr-2012 at 5:59pm
Hi,

No, I'm not pertaining to partial class.. I'm talking about different assembly here w/c holds another model and entities (with the same type that I used with the Domain Project) to which we will modify and let the Business Layer project to use the customized one..

Thanks,
Von
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 03-Apr-2012 at 3:03pm
Sorry Von but I'm still lost as to what you're trying to achieve.

You have a model with Assembly A containing EntityTypeA

AssemblyA
  Namespace DomainModelA
    public partial class EntityTypeA

Then you want another Assembly B with the exact model composition but with additional fields

AssemblyB
  Namespace DomainModelB
   public partial class EntityTypeA
    public int ExtraProp { get; set; }

Unfortunately, this is not possible in .NET if this is what you're trying to achieve. 
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 03-Apr-2012 at 3:57pm
Hi Denis,

I agree that this is something weird but I'm just asking the possibility of this one.
I'll try to rephrase it, the concept is like this:

We as a software provider has this set of base components of our product.

Example:

1. OurCompany.DomainModel
2. OurCompany.BusinessLayer
3. OurCompany.Forms

Where Forms makes use of BusinessLayer w/c makes use of the DomainModel for the dataaccess. (So there will be entities on that model)
Now, we have a feature of our software called ICE (Intergrated Code Expansion) so kinda plugin or so.
We are letting our customer to override some of the Forms, BusinessLayer and database schema (this is the time  that ORM is not yet existing) by inheriting them and calling the customized components instead of the base one (but in the perspective of the base application, it is just calling the default component)

The requirement of our project now is to make it ICEable, Forms and BusinessLayer has no problem and we see MEF as a way to go to do the work but our problem would be the Model. We're not giving the customer the source code of all the base components, they are just inheriting it, overriding or adding some methods, add some bindings, add some controls to the inherited form and we will call the customized one instead of the default. The problem is the Model, how can we extend the model by just inheriting it our any other Devforce approach and let BusinessLayer use the extended one rather than the default.

Thanks,
Von
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 04-Apr-2012 at 12:29pm
Hmm, it sounds like your question is bordering on architecture and unfortunately I'm not qualified to give such advice. You might want to contact your account representative to see if you can have a discussion with a senior consultant.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down