private async Task SaveFromEntityContainersToDb(List <EntityContainer> containers)
        {
            string           EntityName;
            Type             EntityType;
            dynamic          dbInstance, EntityOperations;
            object           Value;
            PropertyInfo     Prop;
            List <JProperty> JProperties;

            foreach (var container in containers)
            {
                JProperties = ((IEnumerable <JProperty>)container.Entity.Properties()).ToList();
                EntityName  = (string)InvokeGenericMethod("GetValue", typeof(string), new object[] { JProperties.Find(property => property.Name.Equals("CosmosEntityName")).Value });
                EntityType  = GetTypeFromAssembly(Assembly_Entities, EntityName);
                dbInstance  = InvokeGenericMethod("CreateEntityInstance", EntityType, null);
                JProperties.ForEach(Jprop => {
                    Prop  = EntityType.GetProperty(Jprop.Name);
                    Value = InvokeGenericMethod("GetValue", Prop.PropertyType, new object[] { Jprop.Value });
                    Prop?.SetValue(dbInstance, Value);
                });
                EntityOperations = GetEntityOperations(EntityName);
                await EntityOperations.Save(dbInstance);
            }
            await Manager.BatchStore.RemoveAsync(container => true);
        }
Beispiel #2
0
        /// <summary>
        /// Create a JSON object using the given JSON properties, but filter null values.
        /// </summary>
        /// <param name="JProperties">JSON properties.</param>
        public static JObject Create(params JProperty[] JProperties)

        => new JObject(JProperties.Where(jproperty => jproperty != null));