0
I have an app C#
MVC
with DDD
and in the repository
I’m making the call like this:
return DbSet.Include(i => i.Cliente).FirstOrDefault(a => a.ProcessoId == processoId);
DbSet->
is in the repositoy
process
public class Processo
{
public int Id { get; set; }
public string Obs { get; set; } <- varchar(max)
public int? ClienteId { get; set; }
public virtual Cliente Cliente { get; set; }
}
Doubts:
Using the DbSet
it is possible to ignore the field Obs
, on the return of the consultation?
(or rather than do SELECT * seja feito SELECT Id, ClienteId, ... Join...
)
Does anyone know any other way to do this and keep the include?
Any component, similar design, suggestions will be welcome.
but it will return Generic object, to return Process must have a new Process{}
– Marco Vinicius Soares Dalalba
@Marcoviniciussoaresdalalba is true it will generate an anonymous type, not generic, a type created at runtime, since the user wants to disregard a field of his class.
– novic
The above solution is good for small objects. When I have a very large object it becomes difficult to maintain, even when adding new properties (when working in a group that is my case), so I’m thinking the opposite, inform the fields I do not want to click on my return object whether this is generic or not.
– nfrigo
@nfrigo so it was added two possible ways. Depending on the case choose one of them ...
– novic