I need to reflect a property for lambda for my Repository, here's the code:
public abstract class RestController<T> : Controller where T : class
{
private readonly IRepository _db;
private readonly string _identityProp;
protected RestController(IRepository db, string identityProp)
{
_db=db;
_identityProp = identityProp;
}
protected virtual void Delete(T item)
{
var value = item.GetType().GetProperty(_identityProp).GetValue(item, null);
var items = _db.All<T>()
.Where(i=>i.GetType().GetProperty(_identityProp)==val)
.ToList();
items.ForEach(x=>_db.Delete(x));
_db.CommitChanges();
return Json("success");
}
}
but the result of lambda is an empty list... Help please, what I'm doing wrong?