I have an old function that we used for lookup tables I need some help with it converting it to entity framework. i no i need to use something like type entitytype to get access to the entities columns but i am at a aloos to what next
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;
}
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;
}