Code First: Independent associations vs. Foreign key associations?

前端 未结 4 1238
醉梦人生
醉梦人生 2020-11-22 01:07

I have a mental debate with myself every time I start working on a new project and I am designing my POCOs. I have seen many tutorials/code samples that seem to favor fo

4条回答
  •  没有蜡笔的小新
    2020-11-22 01:23

    I favour the object approach to avoid unnecessary lookups. The property objects can be just as easily populated when you call your factory method to build the whole entity (using simple callback code for nested entities). There are no disadvantages that I can see except for memory usage (but you would cache your objects right?). So, all you are doing is substituting the stack for the heap and making a performance gain from not performing lookups. I hope this makes sense.

提交回复
热议问题