1

I'm recently concerned in the problems we have with Entity Framework and we may need to find a replacement. According to ORMBattle, the best candidate is DataObjects.Net, the result of my initial investigations are very promising, except one feature that we need in our structure:

Consider two classes: Order and Customer, in class "Order" I have a "Customer" navigation property (and probably an "Orders" navigation property in the Customer class). I also need a property CustomerID in class Order. this is totally possible in lowly EF4.

How can I achieve this goal?

Alireza
  • 5,421
  • 5
  • 34
  • 67
  • 1
    But introducing FKs to EF 4.0 was a workaround to solve some issues with independent association. You should not need FKs at all in object world and as I know DataObjects doesn't support FK properties. – Ladislav Mrnka Jul 09 '12 at 09:22
  • Well, the the sentence "You should not need FKs at all in object world" is based on certain assumptions about the patterns of object usage. It can't be (at least I can't) directly inferred from OOP principles and best practices. I have an interesting architecture, very modular, fast and flexible, that highly depends on having the Identifier of other objects as properties, as well as actual references to the objects. – Alireza Jul 09 '12 at 11:01

1 Answers1

2

you can add non-persistent property with special getter that does the job:

public long CustomerId
{
  get
  {
    return GetReferenceKey(TypeInfo.Fields["Customer"]).Value.GetValue<long>(0);
  }
}

The setter can be added in the same manner.

Hope that helps.

P.S.
This is a copy of the original answer that can be found on the official DataObjects.Net support site.

Dmitry
  • 424
  • 2
  • 4