protected int[] nextIds(statdataEntities ctx, String name, int count) { int nRet = 0; string sname = name.Trim().ToLower(); var q = from x in ctx.DbKeys where x.Nom.Trim().ToLower() == sname select x; if (q.Count() > 0) { DbKey p = q.First(); nRet = p.Valeur; p.Valeur = nRet + count; } else { DbKey p = new DbKey(); p.Nom = sname; p.Valeur = count + 1; ctx.DbKeys.Add(p); ctx.SaveChanges(); nRet = 1; } int[] pRet = new int[count]; for (int i = 0; i < count; ++i) { pRet[i] = nRet + i; } return pRet; }
protected int nextId(statdataEntities ctx, String name) { int nRet = 0; string sname = name.Trim().ToLower(); var q = from x in ctx.DbKeys where x.Nom.Trim().ToLower() == sname select x; if (q.Count() > 0) { DbKey p = q.First(); nRet = p.Valeur; p.Valeur = nRet + 1; } else { DbKey p = new DbKey(); p.Nom = sname; p.Valeur = 2; ctx.DbKeys.Add(p); ctx.SaveChanges(); nRet = 1; } return nRet; }