Example #1
0
        private static void _addCustomentity(Dictionary <Type, List <EntityInfo> > saveMap, object entityToAdd, Type typeOfEntityToAdd, ContextProvider context, EntityState entityState = EntityState.Modified, bool forceUpdate = true)
        {
            List <EntityInfo> entityInfoList = new List <EntityInfo>();

            // check if the type exists in the savemap, if not create it
            if (!saveMap.ContainsKey(typeOfEntityToAdd))
            {
                saveMap.Add(typeOfEntityToAdd, entityInfoList);
            }
            else
            {
                saveMap.TryGetValue(typeOfEntityToAdd, out entityInfoList);
            }

            EntityInfo entity = context.CreateEntityInfo(entityToAdd, entityState);

            entity.ForceUpdate       = forceUpdate;
            entity.OriginalValuesMap = new Dictionary <string, object>();
            entity.UnmappedValuesMap = new Dictionary <string, object>();

            if (entity.AutoGeneratedKey == null)
            {
                dynamic autoGeneratedKey = new ExpandoObject();
                autoGeneratedKey.propertyName         = "Id";
                autoGeneratedKey.autoGeneratedKeyType = AutoGeneratedKeyType.KeyGenerator.ToString();
                entity.AutoGeneratedKey = new AutoGeneratedKey(entityToAdd, autoGeneratedKey);
            }

            entityInfoList.Add(entity);
        }