Esempio n. 1
0
        public void Add <T>(Guid id, T obj, Func <T, string> nameProvider = null) where T : CatalogObjectBase
        {
            var sql =
                "INSERT INTO catalog (id, name, catalogType, content) VALUES (@id, @name, @catalogType, @content)";
            var catalogType = CatalogObjectExtensions.GetCatalogTypeFromAttribute <T>();
            var name        = nameProvider == null
                ? catalogType + "_" + id
                : nameProvider(obj);
            var json       = JsonConvert.SerializeObject(obj);
            var parameters = new { id = id.ToString(), name, catalogType, content = json };

            _provider.ExecuteSqlite(sql, parameters);
        }