2

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?

2
  • 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. Commented Jul 9, 2012 at 9: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. Commented Jul 9, 2012 at 11:01

1 Answer 1

3
+50

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.