Generic Loop through entity
Does anyone no how I would create a generic function to loop through
lookup tables based on passing the entity name the old function we had was
as follows which was fine for data tables the second vaiable i no i need
to use for entityes but I am at aloss for the rest of code.
public int GetCode(string value, Type entityType, string nextnoType)
{
int code = 0;
//DataRow[] lookupRecord = lookup.Select(string.Format("desc_ =
'{0}'", value.Replace("'", "''")));
//if (lookupRecord.Length > 0)
// code = (int)lookupRecord[0]["code"];
//else
//{
// DataRow newLookup = lookup.NewRow();
// newLookup["code"] = context.GetNextId(nextnoType);
// newLookup["desc_"] = value;
// lookup.Rows.Add(newLookup);
// code = (int)newLookup["code"];
//}
return code;
}
No comments:
Post a Comment