I am making a query to a table of colonies and returning them in an API in JSON format
colonias = (from c in conn.Colonias
where c.CodigoPostal.Codigo == cp
&& (bool)c.AuActivo
select c).ToList();
return colonias;
if it is returning the colonies:
The problem is that I am including the relations that EF is obtaining from those records:
should I create objects with the results that include only the information I need? or does anyone know a cleaner method?
You can do two things: use a ViewModel and use AutoMapper to map only the properties you want to be displayed or by making a projection and only querying the properties you want (the others will come null).