public ContactsApi(IDatabaseSession session) { this.Id = Guid.NewGuid(); this.session = session; Debug.WriteLine("ContactsApi {0} created and got session {1}", this.Id, this.session.Id); }
public Population(IDatabaseSession session) { this.session = session; new Setup(session).Apply(); this.Person1 = new PersonBuilder(this.session) .WithUserName("*****@*****.**") .WithFirstName("person1 first name") .WithLastName("person1 last name") .WithUserEmail("*****@*****.**") .WithUserEmailConfirmed(true) .WithUserPasswordHash("ADhrQUXHNLCelscP3NfZxpld7jRMOHkfxd8WRb9HtvgqS4vHKRzQCiIlZuj3qZ98kQ==") .Build(); this.Person2 = new PersonBuilder(this.session) .WithUserName("*****@*****.**") .WithFirstName("person2 first name") .WithLastName("person2 last name") .WithUserEmail("*****@*****.**") .WithUserEmailConfirmed(true) .WithUserPasswordHash("ADhrQUXHNLCelscP3NfZxpld7jRMOHkfxd8WRb9HtvgqS4vHKRzQCiIlZuj3qZ98kQ==") .Build(); new UserGroups(this.session).Administrators.AddMember(this.Person1); this.session.Derive(true); this.session.Commit(); }
public NHibernateUnitOfWork(ISession session) { _session = session; _transaction = _session.BeginTransaction(); _databaseSession = new NHibernateDatabaseSession(_session); }
public void ValidateMappingsAgainstDatabase(IDatabaseSession session) { foreach (var currentMapping in this._mappings) { currentMapping.Value.ValidateAgainstDatabase(session, this._converter); } }
public async ValueTask Delete(NodeID nid, IDatabaseSession db, Func <NodeID, IDatabaseSession, ValueTask> next) { var result = next(nid, db); await deleteFromParentFolder(nid, db); await result; }
public async ValueTask Upsert(Node node, IDatabaseSession db, Func <Node, IDatabaseSession, ValueTask> next) { var result = next(node, db); await updateParentFolder(node, db); await result; }
/// <summary> /// Validates the Query SQL statement against database engine for its syntax and structural correctness. /// Validates only statement in <see cref="SqlStatement"/>. If derived class contains more than this one /// SQL statement - override this implementation and add all statement validations to it. /// </summary> /// <param name="databaseSession">The database session object.</param> /// <exception cref="DatabaseStatementSyntaxException">Throws when <see cref="SqlStatement"/> is incorrect.</exception> public virtual void Validate(IDatabaseSession databaseSession) { string result = databaseSession.QueryFirstOrDefault <string>("SELECT dbo.CheckSql(@tsql, @parameterTypes)", new { tsql = this.SqlStatement, parameterTypes = MsSqlValidationHelpers.GetParameterTypes(this.Parameters) }); if (result != "OK") { throw new DatabaseStatementSyntaxException(result, this.SqlStatement); } }
protected NHQueryableRepository(IDatabaseSession databaseSession) { if (databaseSession == null) { throw new ArgumentNullException(nameof(databaseSession)); } Session = databaseSession.Session; }
public SqlServerDurableIncoming(IDatabaseSession session, DatabaseSettings settings, JasperOptions options) { _session = session; _settings = settings; _findAtLargeEnvelopesSql = $"select top {options.Retries.RecoveryBatchSize} body from {settings.SchemaName}.{IncomingTable} where owner_id = {TransportConstants.AnyNode} and status = '{TransportConstants.Incoming}'"; _cancellation = options.Cancellation; }
public SqlServerDurableIncoming(IDatabaseSession session, DatabaseSettings databaseSettings, AdvancedSettings settings) { _session = session; _databaseSettings = databaseSettings; _findAtLargeEnvelopesSql = $"select top {settings.RecoveryBatchSize} body, attempts from {databaseSettings.SchemaName}.{IncomingTable} where owner_id = {TransportConstants.AnyNode} and status = '{EnvelopeStatus.Incoming}'"; _cancellation = settings.Cancellation; }
public async ValueTask Delete(NodeID nodeId, IDatabaseSession db, Func <NodeID, IDatabaseSession, ValueTask> next) { var store = db.GetPartition(nodeId).Value; await store.DeleteNodeAsync(nodeId); if (next != null) { throw new Exception("Next should be null for the that last merge writer middleware."); } }
public async ValueTask Upsert(Node node, IDatabaseSession db, Func <Node, IDatabaseSession, ValueTask> next) { var store = db.GetPartition(node).Value; await store.UpsertNode(node); if (next != null) { throw new Exception("Next should be null for the that last writer middleware."); } }
private async ValueTask updateParentFolder(Node node, IDatabaseSession db) { var parentPath = ParentPath(new Uri(node.Id.Iri)); // avoid recursive loops if (parentPath.Equals(node.Id)) { return; } await AddToParentsChildrenCollection(parentPath, node.Id, FileTypes.FromNode(node), db); }
private async ValueTask deleteFromParentFolder(NodeID nid, IDatabaseSession db) { var parentPath = ParentPath(new Uri(nid.Iri)); // avoid recursive loops if (parentPath.Equals(nid)) { return; } var parent = await db.Read(parentPath); await RemoveFromParentsChildrenCollection(parent, nid, db); }
public CreatedResponse Run(IDatabaseSession dbSession) { var clientId = entity.Id; var recordChanges = entity as IRecordChangeInfo; var newRecord = dbSession.Insert <T>(this.BuildSql(), entity); return(new CreatedResponse { ClientId = clientId, ServerId = newRecord.Id, RowVersion = newRecord.RowVersion }); }
public virtual void Dispose() { if (this.session != null) { this.session.Rollback(); this.session = null; } if (this.session2 != null) { this.session2.Rollback(); this.session2 = null; } }
protected DurableOutgoing(IDatabaseSession session, DatabaseSettings settings, JasperOptions options) { _session = session; _findUniqueDestinations = $"select distinct destination from {settings.SchemaName}.{OutgoingTable}"; _deleteOutgoingSql = $"delete from {settings.SchemaName}.{OutgoingTable} where owner_id = :owner and destination = @destination"; _cancellation = options.Cancellation; _findOutgoingEnvelopesSql = determineOutgoingEnvelopeSql(settings, options); }
public SchoolClassController(ISchoolClassService scoolClassService, IMappingEngine mappingEngine, IDropdownQueries dropdownQueries, ISchoolClassTeacherService schoolClassTeacherService, ISchoolClassStudentService schoolClassStudentService, ISchoolClassSubjectService schoolClassSubjectService, IDatabaseSession databaseSession) { _scoolClassService = scoolClassService; _mappingEngine = mappingEngine; _dropdownQueries = dropdownQueries; _schoolClassTeacherService = schoolClassTeacherService; _schoolClassStudentService = schoolClassStudentService; _schoolClassSubjectService = schoolClassSubjectService; _databaseSession = databaseSession; }
private static void AddRec(IDatabaseSession sess) { var rec = new CommandQueueRec { Id = Guid.NewGuid(), TimeQueued = DateTime.UtcNow, CommandType = "Test", TemplateName = "TemplateName", TemplateFields = "fields" }; var cmdQueueMap = new CommandQueueMap(sess); cmdQueueMap.Insert(rec); }
public DeletedResponse Run(IDatabaseSession dbSession) { IDictionary <string, object> parameters; var changeInfo = entity as IRecordChangeInfo; var deleteSql = this.BuildSql(); parameters = this.GetParameters(changeInfo?.RowVersion); dbSession.DeleteSingle(deleteSql, parameters, this.entity); return(new DeletedResponse() { Success = true }); }
public UpdatedResponse Run(IDatabaseSession dbSession) { IDictionary <string, object> parameters; var changeInfo = this.entity as IRecordChangeInfo; var updateSql = this.BuildSql(); parameters = this.GetParameters(changeInfo?.RowVersion); var record = dbSession.UpdateSingle(updateSql, parameters, this.entity); return(new UpdatedResponse() { ServerId = this.entity.Id, RowVersion = record.RowVersion }); }
public PmsWorkArea( IDatabaseSession databaseSession, IAddressRepository addresses, ICollaboratorRepository collaborators, ICommercialGuestRepository commercialGuests, IIndividualGuestRepository individualGuests, IMaintenanceJobRepository maintenanceJobs, IPassportRepository passports, IRoomRepository rooms) : base(databaseSession) { Addresses = addresses; Collaborators = collaborators; CommercialGuests = commercialGuests; IndividualGuests = individualGuests; MaintenanceJobs = maintenanceJobs; Passports = passports; Rooms = rooms; }
public static IAsyncEnumerable <object> RemoteRun(byte[] assemblyStream, IDatabaseSession queryDatabaseSession) { var result = ExecuteAndUnload(Assembly.GetExecutingAssembly().Location, assemblyStream, "remoteRun", out var alcWeakRef, assembly => { //using (token.Scope()) { IAsyncEnumerable <object> results = null; var subTypes = assembly.DefinedTypes.Where(dt => dt.IsAssignableTo(typeof(EkatiQuery))).ToList(); if (subTypes.Any()) { var pipeline = subTypes.Select(info => { if (Activator.CreateInstance(info.AsType()) is Standard stdQuery) { return(stdQuery.Query(queryDatabaseSession).Prepend($"Running: {info.FullName}")); } if (Activator.CreateInstance(info.AsType()) is Single singleQuery) { var qr = new[] { $"Running: {info.FullName}", singleQuery.Query(queryDatabaseSession) }.ToAsyncEnumerable(); return(qr); } return(new[] { "No query detected" }.ToAsyncEnumerable()); }).ToAsyncEnumerable().SelectMany(x => x); return(pipeline); } return(results); } }); return(result); }
public DurableNodes(IDatabaseSession session, DatabaseSettings settings, CancellationToken cancellation) { _session = session; _cancellation = cancellation; _fetchOwnersSql = $@" select distinct owner_id from {settings.SchemaName}.{IncomingTable} where owner_id != 0 and owner_id != @owner union select distinct owner_id from {settings.SchemaName}.{OutgoingTable} where owner_id != 0 and owner_id != @owner"; _reassignDormantNodeSql = $@" update {settings.SchemaName}.{IncomingTable} set owner_id = 0 where owner_id = @owner; update {settings.SchemaName}.{OutgoingTable} set owner_id = 0 where owner_id = @owner; "; }
public static async Task AddDoc(this IDatabaseSession data, string iri, params KeyValue[] withProps) { var nowTicks = DateTime.Now.Ticks; await data.Upsert(new Node { Id = new NodeID { Iri = iri }, Attributes = new Map { Items = withProps.Concat(new KeyValue[] { ("hi", "there", nowTicks), ("hii", 18.7d, nowTicks), ("hiii", 7, nowTicks), ("hiiii", "there4", nowTicks), ("someMap", new KeyValue[] { ("m1", 11.3f, nowTicks), ("m2", 8, nowTicks), ("m3", new Primitive[] { 3.123f, 3, 3L, (Map) new KeyValue[] { ("n1", "v3", nowTicks), ("n2", "v4", nowTicks), ("n3", new Primitive[] { 4.123f, 4, 4L, }, nowTicks) }, nowTicks
public override async IAsyncEnumerable <object> Query(IDatabaseSession db) { var traversed = 0; var parResult = System.Threading.Tasks.Parallel.For(0, 10, async(i) => { var item = db.Read(Utils.Id("ekati:/etc/assembly")); if (item.IsCompletedSuccessfully) { var res = item.Result; var it = res.Attributes.Items.FirstOrDefault(i => i.Key.TryGet <NodeID>(out var nid) && nid.Iri == "ekati:attr/children"); if (it != null) { if (it.Value.TryGet <Map>(out var kids) && kids != null) { foreach (var k in kids.Items) { if (k.Key.TryGet <NodeID>(out var doc)) { var sub = await db.Read(doc); traversed++; } } } } traversed++; } else { await item; traversed++; } }); yield return(new { traversed, parResult }); }
public FakeRepository(IDatabaseSession databaseSession) { _databaseSession = databaseSession; }
public SchoolClassStudentService(IDatabaseSession databaseSession) { _databaseSession = databaseSession; }
public IDatabaseSession GetSession2() { return this.session2 ?? (this.session2 = this.GetPopulation2().CreateSession()); }
public TeacherService(IDatabaseSession databaseSession) { _databaseSession = databaseSession; }
public SchoolClassTeacherService(IDatabaseSession databaseSession) { _databaseSession = databaseSession; }
protected void Init(bool setup) { if (setup) { var stringReader = new StringReader(Fixture.DefaultXml); var reader = new XmlTextReader(stringReader); Config.Default.Load(reader); } else { Config.Default.Init(); } this.databaseSession = Config.Default.CreateSession(); SecurityCache.Invalidate(); }
public virtual void TearDown() { this.databaseSession.Rollback(); this.databaseSession = null; }
public BrightStarDataProvider(GrpcFileStore fileStore) { _databaseSession = fileStore.Session(); }
public override void ValidateAgainstDatabase(IDatabaseSession session, ITypeToColumnTypeConverter converter) { this.ValidateAgainstTableMetaData(session.GetTableMetaData(this.TableName), converter); }
public SchoolClassSubjectService(IDatabaseSession databaseSession) { _databaseSession = databaseSession; }
public SqlServerDurableOutgoing(IDatabaseSession session, DatabaseSettings settings, AdvancedSettings options) : base(session, settings, options) { _session = session; _settings = settings; _cancellation = options.Cancellation; }
public ProductRepository(IDatabaseSession session) : base(session) { }
public ContactRepository(IDatabaseSessionFactory databaseSessionFactory) { _dbSession = databaseSessionFactory.CreateSession(CONNECTION_STRING); }
public ClientRepository(IDatabaseSession session) : base(session) { }
public async ValueTask <Node> Read(NodeID nodeId, IDatabaseSession db, Func <NodeID, IDatabaseSession, ValueTask <Node> > next) { return(await db.GetPartition(nodeId).Value.LoadNodeAsync(nodeId)); }