Example #1
0
        public static List<UpdateBuilder> AttachUpdateMetaData(this BsonDocument doc, List<UpdateBuilder> builders, IMongoIdentity user)
        {
            builders = builders ?? new List<UpdateBuilder>();
            builders.AddRange(from name in doc.Names where name != "Id" select Update.Set(name, doc.GetValue(name)));

            builders.Add(Update.Set("LastUpdatedBy", user.GetDisplayName()));
            builders.Add(Update.Set("LastModifiedOn", DateTime.Now));

            return builders;
        }
Example #2
0
        public static List<UpdateBuilder> AttachUpdateMetaData(this object obj, IMongoIdentity user, double schema)
        {
            var builders = new List<UpdateBuilder>();

            obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Where(x => x.GetValue(obj, null) != null)
                .ToList()
                .ForEach(p =>
                {
                    var val = BsonValue.Create(p.GetValue(obj, null));
                    builders.Add(Update.Set(p.Name, val));
                });

            builders.Add(Update.Set("__schemaVersion", schema));
            builders.Add(Update.Set("LastUpdatedBy", user.GetDisplayName()));
            builders.Add(Update.Set("LastModifiedOn", DateTime.Now));

            return builders;
        }