Exemple #1
0
        public LibItem Add(LibItem item)
        {
            item.OperTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

            this.LibCollection.InsertOne(item);

            return(item);
        }
Exemple #2
0
        // 更新
        public async Task <long> Update(LibItem item)
        {
            IMongoCollection <LibItem> collection = this.LibCollection;

            var filter = Builders <LibItem> .Filter.Eq("id", item.id);

            //var filter = Builders<LibItem>.Filter.Eq("libCode", item.libCode);
            var update = Builders <LibItem> .Update
                         .Set("libCode", item.libCode)
                         .Set("libName", item.libName)
                         .Set("libP2PAccount", item.libP2PAccount)
                         .Set("comment", item.comment)
                         .Set("OperTime", item.OperTime);

            UpdateResult ret = await collection.UpdateOneAsync(filter, update);

            return(ret.ModifiedCount);
        }