You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am pretty new to HotChocolate so my question might be fairly obvious but I would like to have some expert opinion on this anyway.
Currently, I have a real estate object with just some basic fields like Id, Title, Type. Since a real estate has lots of parameters, I would like to group them into categories like Geo, Sizes, Features, etc.
My question is now about the categories. Since I will only query real estate and never query just Sizes for example, I would like to know how you would model this. My first instinct is to have objects for Geo, Sizes, Features etc. only for Entity Framework so that they can be persisted. Furthermore, I would need classes GeoInput, SizesInput and FeaturesInput to be able to populate the Entity Framework classes.
My method AddRealEstate() would look something like that:
public async Task<AddRealEstatePayload> AddRealEstateAsync(
AddRealEstateInput input,
[Service] ApplicationDbContext context)
{
var RealEstate = new RealEstate
{
Id = input.Id,
Title = input.Title,
SortOrder = input.SortOrder,
Geo = new Geo
{
Id = input.Geo.Id,
PostalCode = input.Geo.PostalCode,
City = input.Geo.City,
Street = input.Geo.Street
}
};
context.RealEstates.Add(RealEstate);
await context.SaveChangesAsync();
return new AddRealEstatePayload(RealEstate);
}
Is that a good idea or would you model it differently?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there,
I am pretty new to HotChocolate so my question might be fairly obvious but I would like to have some expert opinion on this anyway.
Currently, I have a real estate object with just some basic fields like Id, Title, Type. Since a real estate has lots of parameters, I would like to group them into categories like Geo, Sizes, Features, etc.
My question is now about the categories. Since I will only query real estate and never query just Sizes for example, I would like to know how you would model this. My first instinct is to have objects for Geo, Sizes, Features etc. only for Entity Framework so that they can be persisted. Furthermore, I would need classes GeoInput, SizesInput and FeaturesInput to be able to populate the Entity Framework classes.
My method
AddRealEstate()
would look something like that:Is that a good idea or would you model it differently?
Any help is very much appreciated.
Regards,
Dirk.
Beta Was this translation helpful? Give feedback.
All reactions