public static long GenerateSequence(string sequenceName) { using (var objectSpace = ApplicationHelper.Instance.Application.CreateObjectSpace()){ long seq = 0; GenerateSequence(objectSpace.Session(), sequenceName, l => seq = l); Instance.Accept(); return(seq); } }
public static void SetNextSequence(ITypeInfo typeInfo, string prefix, long nextId) { var objectByKey = Instance._explicitUnitOfWork.FindObject(_sequenceObjectType, GetCriteria(prefix + typeInfo.FullName), true); Instance._sequence = objectByKey != null ? (ISequenceObject)objectByKey : CreateSequenceObject(prefix + typeInfo.FullName, Instance._explicitUnitOfWork); Instance._sequence.NextSequence = nextId; Instance._explicitUnitOfWork.FlushChanges(); Instance.Accept(); }
private static void SessionOnAfterCommitTransaction(object sender, SessionManipulationEventArgs e) { ((Session)sender).AfterCommitTransaction -= SessionOnAfterCommitTransaction; Instance.Accept(); }