How are you serializing your data?
Just don't serialize your wines
collection property. Depending on your serialization mechanism you can either mark it with an attribute (ie. ScriptIgnore
) or define concrete types (since you don't like anonymous types) and use AutoMapper to copy data.
Binding your EF entities directly to the response of the API is not the best design choice. Every time you modify your db schema your API will change. You could define separate classes that your API controllers will return and use AutoMapper to copy data. That way you decouple your DB schema from your API.
namespace API {
class Wine {
// properties that you want to return goes here
}
}
Mapper.CreateMap<Wine, API.Wine>(); // Only once during app start
Mapper.Map<Wine, API.Wine>(wine); // AutoMapper will copy data using conventions