Tuesday, May 1, 2018

Entity framework returning multiple object types from a repository

Let's say I have a repository wrapped around entity framework that returns my domain objects. Entity framework lets you include reference tables as included columns. I don't want my domain objects to have those weird navigation objects the way entity framework has. Is it acceptable to return a god object that potentially has every object type in the model?

For example I have

Table Account id name accountStatusId

Table AccountStatus id name

An account repository would return accounts. But I want to include the account status too to not have the n+1 problem of looking up the account status I can include the account status as an included columns.

If i don't have a class property on my POCOAccount class for the account status how else can I accomplish with without a god object I insert every loaded record into?

With a god object I can return a flat json response which helps with duplicating records all over the place with a nested response.

This sort of brings up a nested vs flat response debate found on https://softwareengineering.stackexchange.com/questions/350623/flat-or-nested-json-for-hierarchal-data

Entity framework returning multiple object types from a repository Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team