Im making this method retrieve records from the Data Base. As you can see i Want to return a List where ITieneID is an Interface defined on my business layer.
AtlasWFM_Entities.Clases.Area implements that interface. It is pretty clear that this is not a good way to accomplishing it (even though it compiles correctly)
public override List<ITieneID> Buscar(ITieneID elementoPatron)
{
List<ITieneID> result = new List<ITieneID>();
var resultado = from a in base.Repository.Context.Areas
where a.areaID.Equals(elementoPatron.ID) || a.areaDescripcion.Contains(elementoPatron.Descripcion)
select new AtlasWFM_Entities.Clases.Area
{
ID = a.areaID,
Descripcion = a.areaDescripcion,
Estado = a.areaEstado,
};
foreach (var r in resultado)
{
ITieneID t = new AtlasWFM_Entities.Clases.Area
{
ID = r.ID,
Descripcion = r.Descripcion,
Estado = r.Estado,
};
result.Add(t);
}
return result;
}
Any Ideas how to improve this??
Thanks in advance.