Example #1
0
 public Range GetIdRange(string machine)
 {
     IdRange range;
     using (var context = new IdRangesDataContext()) {
         var ranges = context.IdRanges;
         //fetch existing range if there is one
         if ((range = ranges.SingleOrDefault(r => r.Machine == machine)) == null) {
             //otherwise generate a new range
             range = new IdRange() { Machine = machine };
             range.Min = ranges.Count() > 0 ? ranges.Max(r => r.Max) + 1 : Settings.Default.MinClientId;
             range.Max = range.Min + Settings.Default.IdRange - 1;
             context.IdRanges.InsertOnSubmit(range);
             context.SubmitChanges();
         }
         return new Range(range.Min, range.Max);
     }
 }
Example #2
0
        public Range GetIdRange(string machine)
        {
            IdRange range;

            using (var context = new IdRangesDataContext()) {
                var ranges = context.IdRanges;
                //fetch existing range if there is one
                if ((range = ranges.SingleOrDefault(r => r.Machine == machine)) == null)
                {
                    //otherwise generate a new range
                    range = new IdRange()
                    {
                        Machine = machine
                    };
                    range.Min = ranges.Count() > 0 ? ranges.Max(r => r.Max) + 1 : Settings.Default.MinClientId;
                    range.Max = range.Min + Settings.Default.IdRange - 1;
                    context.IdRanges.InsertOnSubmit(range);
                    context.SubmitChanges();
                }
                return(new Range(range.Min, range.Max));
            }
        }
Example #3
0
 partial void DeleteIdRange(IdRange instance);
Example #4
0
 partial void UpdateIdRange(IdRange instance);
Example #5
0
 partial void InsertIdRange(IdRange instance);
Example #6
0
 partial void DeleteIdRange(IdRange instance);
Example #7
0
 partial void UpdateIdRange(IdRange instance);
Example #8
0
 partial void InsertIdRange(IdRange instance);