Ejemplo n.º 1
0
            /// <summary>
            /// Insert a generic MongoEntity which is in New state
            /// </summary>
            public void GenericInsert(MongoContext ctx, MongoEntity ent)
            {
                if (ctx.Debug)
                {
                    Debug.WriteLine($"Insert ent type={ent.GetType()} id={ent.Id}");
                }

                Collection.InsertOne((T)ent);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// enclose the given entity taking a backup
            /// </summary>
            public AttachedMongoEntity(MongoEntity entity, Type type = null)
            {
                type = type ?? entity.GetType();

                NominalType = type;

                Entity = entity;

                ResetOrigEntity();
            }
Ejemplo n.º 3
0
            /// <summary>
            /// Remove a generic MongoEntity which is in Deleted state
            /// </summary>
            /// <param name="ent"></param>
            public void GenericDelete(MongoContext ctx, MongoEntity ent)
            {
                if (ctx.Debug)
                {
                    Debug.WriteLine($"Delete ent type={ent.GetType()} id={ent.Id}");
                }

                var filter = Builders <T> .Filter.Eq((x) => x.Id, ent.Id);

                Collection.DeleteOne(filter);
            }