1

Ive been playing around with the entity framework with an idea for creating a web service to be consumed by an application in sharepoint that a 3rd party developer is creating. Basically i need to return a list of jobs e.g list based on some search criteria. I wanted to use the EF so i have something scalable however it seems returning POCO's from a web service is harder than i imagined it to be. Are web services and EF / POCO's meant to work together. Does anyone have any good examples or can point me to some.

Richard Banks
  • 2,946
  • 5
  • 34
  • 71
  • look at my answer here: http://stackoverflow.com/questions/7474267/mvc3-and-entity-framework/7474357#7474357 if you structure your whole project correctly with interfaces and entities, then you can expose only the entities you want via web services, try to have no dependencies on EF outside the DAL. – Davide Piras Oct 11 '11 at 07:47
  • @Davide Piras thanks for that. Seems logical. What about consuming the web service? I read somewhere that the consumer has to reference the entity namespace to use the returned objects. Do you know if this is correct – Richard Banks Oct 11 '11 at 07:53
  • of course and this is the reason why I suggested such layered architecture in my other post. Are you planning to use XML Web Services or WCF? in WCF you have DataContracts, in XML Web Services not but still it's way better when you have your classes defined in a shared assembly used by both server and clients and not clients infering the entities from the service. – Davide Piras Oct 11 '11 at 07:55

1 Answers1

0

Are web services and EF / POCO's meant to work together.

Yes. The only thing you must to ensure is to make your entities serializable - POCO entities can contain circular references which are not serializable by default.

What about consuming the web service? I read somewhere that the consumer has to reference the entity namespace to use the returned objects.

This is not true with POCOs. This is only true with Self tracking entities.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670