Skip to main content
added 34 characters in body
Source Link
JanDotNet
  • 8.6k
  • 2
  • 22
  • 48

What I am wondering about here is if the GetAll() method could me a bit nicer.

The entity framework already has a method for loading related data: See this link section 'Include related data'. Older versions of the entity framework have similar methods.

That would turn your GetAll method into a one liner ;)

_context.Organizations.Include(o => o.Address);

ThinkAs Gert Arnold already mentioned, think about the necessity of the repository class. The DbContext already is something like a flexibly repository... IMHO it is not necessarily required to add another abstraction (except if the abstraction really adds value).

What I am wondering about here is if the GetAll() method could me a bit nicer.

The entity framework already has a method for loading related data: See this link section 'Include related data'. Older versions of the entity framework have similar methods.

That would turn your GetAll method into a one liner ;)

_context.Organizations.Include(o => o.Address);

Think about the necessity of the repository class. The DbContext already is something like a flexibly repository... IMHO it is not necessarily required to add another abstraction (except if the abstraction really adds value).

What I am wondering about here is if the GetAll() method could me a bit nicer.

The entity framework already has a method for loading related data: See this link section 'Include related data'. Older versions of the entity framework have similar methods.

That would turn your GetAll method into a one liner ;)

_context.Organizations.Include(o => o.Address);

As Gert Arnold already mentioned, think about the necessity of the repository class. The DbContext already is something like a flexibly repository... IMHO it is not necessarily required to add another abstraction (except if the abstraction really adds value).

Source Link
JanDotNet
  • 8.6k
  • 2
  • 22
  • 48

What I am wondering about here is if the GetAll() method could me a bit nicer.

The entity framework already has a method for loading related data: See this link section 'Include related data'. Older versions of the entity framework have similar methods.

That would turn your GetAll method into a one liner ;)

_context.Organizations.Include(o => o.Address);

Think about the necessity of the repository class. The DbContext already is something like a flexibly repository... IMHO it is not necessarily required to add another abstraction (except if the abstraction really adds value).