예제 #1
0
        static internal int GetID(String table, String connectionString)
        {
            Tuple<int /* last */, int /* remaining */> innerDic = null;
            int id = 0; int remaining = 0;
            if (_idCache.TryGetValue(table, out innerDic))
            {
                id = innerDic.Item1; remaining = innerDic.Item2;
            }
            else
                innerDic = new Tuple<int, int>(0, 0);

            if (innerDic.Item2 == 0)
            {
                var db = new DataClasses1DataContext(connectionString);
                id = db.GetID(table, 20);
                remaining = 20;
            }
            _idCache[table] = new Tuple<int, int>(id + 1, remaining - 1);
            return id;
        }