public void Test_Insert_JsonDocument() { var options = new JsonSerializerOptions(); var store = DatabaseHelper.Default.GetStore(); store.Use(new JsonBindingContractResolver(options)); var data = "{ \"Id\": 12, \"Title\": \"Hello World!\" }"; var schema = store.GetSchema(typeof(JsonDocument)); var buffer = new QueryBuffer(schema, QueryType.List); buffer.Insert(data, ("", "") ); var result = buffer.Commit <JsonDocument>(); result.ShouldNotBeNull(); Should.NotThrow(() => { var id = result.RootElement.GetProperty("Id"); var title = result.RootElement.GetProperty("Title"); id.GetInt32().ShouldBe(12); title.GetString().ShouldBe("Hello World!"); }); }
public static void InsertAll(this QueryBuffer buffer, IDataReader dataReader) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } do { buffer.Insert(dataReader); }while (dataReader.NextResult()); }
public static QueryBuffer Insert <TSource>(this QueryBuffer buffer, TSource source, RelationHeader sourceHeader) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } IRelation relation = new Relation(buffer.Store.From(source), sourceHeader); buffer.Insert(relation); return(buffer); }
public static QueryBuffer Insert <TSource>(this QueryBuffer buffer, TSource source, IEnumerable <string> sourceHeader) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } ISchema schema = buffer.Store.GetSchema(typeof(TSource)); buffer.Insert(source, schema.Select(sourceHeader)); return(buffer); }
public void Test_Insert_Json_NoContract() { var store = DatabaseHelper.Default.Store; var data = "{ \"Id\": 12 }"; var schema = store.GetSchema(typeof(BlogJsonView)); var buffer = new QueryBuffer(schema, QueryType.List); Should.Throw <BindingException>(() => { buffer.Insert(data, ("", "Blog") ); }); }
public static QueryBuffer Insert(this QueryBuffer buffer, IRelation relation) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (relation == null) { throw new ArgumentNullException(nameof(relation)); } using IDataReader dataReader = relation.GetDataReader(); buffer.Insert(dataReader); return(buffer); }
public void Test_Insert_Json() { var options = new JsonSerializerOptions(); var store = DatabaseHelper.Default.GetStore(); store.Use(new JsonBindingContractResolver(options)); var data = "{ \"Id\": 12, \"Title\": \"Hello World!\" }"; var schema = store.GetSchema(typeof(BlogJsonView)); var buffer = new QueryBuffer(schema, QueryType.List); buffer.Insert(data, ("", "Blog") ); var result = buffer.Commit <BlogJsonView>(); result.ShouldNotBeNull(); result.Blog.ShouldNotBeNull(); result.Blog.Id.ShouldBe(12); result.Blog.Title.ShouldBe("Hello World!"); }
public static QueryBuffer Insert(this QueryBuffer buffer, IRelation relation, IEnumerable <IRelationMetadata> targetHeader) => buffer.Insert(relation, targetHeader?.Select(m => m?.Identity.Name));
public static QueryBuffer Insert(this QueryBuffer buffer, IRelation relation, params string[] targetHeader) => buffer.Insert(relation, (IEnumerable <string>)targetHeader);
public static QueryBuffer Insert <TSource>(this QueryBuffer buffer, TSource source, params string[] sourceHeader) => buffer.Insert(source, (IEnumerable <string>)sourceHeader);