I'm trying to write a generic method, and the code below gives errors.
Cannot convert type '
T2
' to 'T1
''
T1
' does not contain a definition for 'Action' and no extension method 'Action' accepting a first argument of type 'T1
' could be found (are you missing a using directive or an assembly reference?)
private List<T2> FillChildControlOnSave<T1, T2>(
ref T1 objEntity, ref List<T1> _entityParent, ref List<T2> _entityDetail)
{
foreach (T2 c in _entityDetail)
{
if (c.Action == XERP.Entity.ActionMode.Add)
objEntity.PlnBOMDetails.Add(c);
var tmp = objEntity.PlnBOMDetails
.Where(p => p.BOMDetailRecordID == c.BOMDetailRecordID &&
p.BOMID == c.BOMID &&
p.IsDeleted == false)
.FirstOrDefault();
if (tmp != null)
if (c.Action == Entity.ActionMode.Delete)
objController.Context.PlnBOMDetails.DeleteObject(tmp);
}
return _entityDetail;
}
If I replace T1
and T2
with PlnBOMMaster,PlnBOMDetail
then above syntax works fine. How to solve this generic method problem?