I start in C# and I want to keep only some information in DB with a condition to a Child and is a Enum.
this is what i want to do but this not work.
var element = await _unitOfWork.Repository<TbElement>()
.All( c => c
.Include( x => x.el )
.ThenInclude( x => x.ChildEl.Type == Type.bottle )
);
My table El:
[ForeignKey("ChildElId")]
public int? ChildElId { get; set; }
public virtual TbChildEl ChildEl { get; set; }
Table ChildEl:
public class TbChildEl : EntiteCSSAbstract
{
public string Name { get; set; }
public string Description { get; set; }
public bool IsActif { get; set; }
public Type Type { get; set; }
public ICollection<TbEl> El { get; set; }
}
class TbEl
{
public int UserId { get; set; }
public virtual ICollection<TbEL> El { get; set; }
}
I want to keep all bottle in this exemple, because is not the real name, but nothing work.
Can someone have a solution. It's meabe easy but I not found how to keep it without take all Id
in Element
and take Id
to ChildEl
with type=bootle
and make a loop if element.El.ChildElId == ChildEl.Id
if working but I know that not the good way and too long to run on Server.