private async Task <PropertiesRecord?> LoadFromDatabaseAsync(PropertiesSchema schema, IBioEntity entity,
                                                              Guid?siteId = null)
 {
     return(schema == null || !_checkIfExists
         ? null
         : await _dbContext.Properties.FirstOrDefaultAsync(s =>
                                                           s.Key == schema.Key &&
                                                           s.EntityType == entity.GetKey() && s.EntityId == entity.Id &&
                                                           (siteId == null || s.SiteId == siteId.Value)));
 }
        private static void RegisterBioEngineProperties <TProperties>(string key, Type entityType,
                                                                      PropertiesRegistrationType registrationType = PropertiesRegistrationType.Entity)
            where TProperties : PropertiesSet, new()
        {
            var schema = Schema.ContainsKey(key) ? Schema[key] : null;

            if (schema == null)
            {
                schema = PropertiesSchema.Create <TProperties>(key);

                Schema.TryAdd(key, schema);
            }

            schema.AddRegistration(key, registrationType, entityType);
        }
 private PropertiesSet DeserializeProperties(PropertiesRecord record, PropertiesSchema schema)
 {
     return((PropertiesSet)JsonConvert.DeserializeObject(record.Data, schema.Type));
 }