Exemple #1
0
        public ServiceResult Add(string tableName, string dataJson)
        {
            var modelBaseJson = new AutoDataBaseEntity().ToJsons();

            var rsJoinJson = $"{dataJson.TrimEnd('}')},{modelBaseJson.TrimStart('{')}";
            // dynamic object
            var model = LightAppStore.JsonToDynamicObject(rsJoinJson);

            LightAppStore.GetCollection(tableName).InsertOne(model);
            return(ServiceResult.Success);
        }
Exemple #2
0
        public ServiceResult Update(string tableName, string dataJson, ObjectId id)
        {
            var modelBaseJson = new AutoDataBaseEntity().ToJsons();

            var rsJson = $"{dataJson.TrimEnd('}')},{modelBaseJson.TrimStart('{')}";

            // dynamic object
            var model = LightAppStore.JsonToDynamicObject(rsJson);

            var filter = Builders <dynamic> .Filter.Eq("_id", id);

            LightAppStore.GetCollection(tableName).FindOneAndReplace <dynamic>(filter, model);

            return(ServiceResult.Success);
        }