internal GenericSeekableNavigator(GenericSeekableNavigator navigator) { this.navigator = navigator.navigator.Clone(); this.nodes = new QueryBuffer<XPathNavigator>(); this.currentPosition = navigator.currentPosition; this.dom = navigator.dom; }
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!"); }); }
static void Main(string[] args) { adapter.Error += Adapter_Error1; adapter.ErrorProcessed += Adapter_ErrorProcessed; //adapter.SelectReader("SELECT * FROM test.test_table WHERE id = 1", (row) => //{ // int id = Convert.ToInt32(row["id"]); //}); QueryBuffer buffer = new QueryBuffer(adapter, 0, true); buffer.Add("query one"); buffer.Add("query two;"); buffer.Add("query three;\r\n"); buffer.Add("query four\r\n"); buffer.Reject(1); buffer.Reject(2); using (QueryBuffer buf = new QueryBuffer(adapter, new TimeSpan(0, 1, 0), 0)) { } var t = buffer.Query; }
internal GenericSeekableNavigator(XPathNavigator navigator) { this.navigator = navigator; this.nodes = new QueryBuffer<XPathNavigator>(4); this.currentPosition = -1L; this.dom = this; }
internal EvalStack(int frameCapacity, int stackCapacity) { this.buffer = new QueryBuffer<Value>(frameCapacity + stackCapacity); this.stack = new StackRegion(new QueryRange(0, stackCapacity - 1)); this.buffer.Reserve(stackCapacity); this.frames = new StackRegion(new QueryRange(stackCapacity, (stackCapacity + frameCapacity) - 1)); this.buffer.Reserve(frameCapacity); this.contextOnTopOfStack = false; }
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, 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 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 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") ); }); }
static internal bool EntryDelegate(EventDescriptor currentEntry, QueryBuffer buffer, ref EnumerationContext context) { if (!DumpAll) { return(false); } if ((currentEntry != null) && (buffer != null)) { currentEntry.EnumerateFields(new QueryFieldDelegate(fieldDelegate), buffer, ref context); } return(true); }
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); }
internal static bool ActiveEntryDelegate(UIntPtr sourceHandle, int index, EventDescriptor descriptor, QueryBuffer entryBuffer, ref EnumerationContext context) { if (!DumpAll) { return false; } if (descriptor != null) { Console.Write("{0:d5}", index); descriptor.EnumerateFields(new QueryFieldDelegate(ActiveFieldDelegate), entryBuffer, ref context); Console.WriteLine(""); } return true; }
public static object CollectionFilter <T>(QueryBuffer query, QueryBuffer.TypeBuffer typeBuf, object result) { var typedResult = result as IEnumerable <T>; if (typedResult != null) { if (typeBuf.Skip != null) { typedResult = typedResult.Skip((int)typeBuf.Skip(query.Context)); } if (typeBuf.Top != null) { typedResult = typedResult.Take((int)typeBuf.Top(query.Context)); } return(typedResult.ToList()); } else { return(result); } }
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 <TSource>(this QueryBuffer buffer, TSource source, params (string Source, string Target)[] mappingHeader)
internal GenericSeekableNavigator() { this.nodes = new QueryBuffer<XPathNavigator>(4); this.currentPosition = -1; }
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 T Commit <T>(this QueryBuffer buffer) => (T)buffer.Commit();
public OpcodeList(int capacity) { this.opcodes = new QueryBuffer<Opcode>(capacity); }
public PreparedQueryPlan PrepareQuery(HarmonyQueryCompilationContext compilationContext) { var rootExpr = RootExpressions[_valueBufferParameter]; var processedOns = new List <object>(); var flatList = new List <Tuple <HarmonyTableExpression, QueryBuffer.TypeBuffer> >(); var typeBuffers = new QueryBuffer.TypeBuffer[] { GetTypeBuffer(rootExpr, flatList) }; var expressionTableMapping = flatList.ToDictionary(kvp => kvp.Item1.RootExpression.ConvertedParameter as Expression, kvp => kvp.Item1 as IHarmonyQueryTable, new ExpressionValueComparer()); var tableList = flatList.Select(tpl => tpl.Item1 as IHarmonyQueryTable).ToList(); //extract all of expressions that might represent a given table and add them to the mapping dictionary foreach (var table in tableList) { foreach (var alias in ((HarmonyTableExpression)table).Aliases) { if (!expressionTableMapping.ContainsKey(alias)) { expressionTableMapping.Add(alias, table); } } } var whereBuilder = new WhereExpressionBuilder(rootExpr.IsCaseSensitive, tableList, expressionTableMapping); var processedWheres = new List <Object>(); var orderBys = new List <Tuple <FileIO.Queryable.FieldReference, bool> >(); foreach (var expr in rootExpr.WhereExpressions) { whereBuilder.VisitForWhere(expr, processedWheres, processedOns); } foreach (var tpl in flatList) { foreach (var expr in tpl.Item1.OnExpressions) { var madeOn = whereBuilder.VisitForOn(expr); if (madeOn != null) { processedOns.Add(madeOn); if (tpl.Item2.JoinOn == null) { tpl.Item2.JoinOn = madeOn; } else { throw new NotImplementedException(); } } } if (tpl.Item1 != rootExpr) { foreach (var expr in tpl.Item1.WhereExpressions) { var madeOn = whereBuilder.VisitForOn(expr); if (madeOn != null) { processedOns.Add(madeOn); if (tpl.Item2.JoinOn != null) { madeOn = new ConnectorPart() { Op = WhereClauseConnector.AndOperator, Left = tpl.Item2.JoinOn, Right = madeOn } } ; tpl.Item2.JoinOn = madeOn; } } } foreach (var expr in tpl.Item1.OrderByExpressions) { var fieldRef = whereBuilder.VisitForOrderBy(expr.Item1); if (fieldRef != null) { orderBys.Add(Tuple.Create(fieldRef, expr.Item2)); } } } var queryBuffer = new QueryBuffer(flatList.Select(tpl => tpl.Item2).ToList()); var fieldReferences = new Dictionary <int, List <FieldDataDefinition> >(); foreach (var queryExpr in flatList) { if (queryExpr.Item1.ReferencedFields.Count > 0) { var bufferIndex = queryBuffer.TypeBuffers.IndexOf(queryExpr.Item2); fieldReferences.Add(bufferIndex, queryExpr.Item1.ReferencedFields); } } var queryPlan = new PreparedQueryPlan(true, processedWheres, fieldReferences, processedOns, orderBys, queryBuffer, ""); return(queryPlan); }
internal Diverger(Opcode tree, Opcode insert) { this.treePath = new QueryBuffer<Opcode>(0x10); this.insertPath = new QueryBuffer<Opcode>(0x10); this.treeOpcode = tree; this.insertOpcode = insert; }
internal MultipleResultOpcode(OpcodeID id) : base(id) { this.flags |= OpcodeFlags.Multiple; this.results = new QueryBuffer<object>(1); }
public static QueryBuffer Insert <TSource>(this QueryBuffer buffer, TSource source, params string[] sourceHeader) => buffer.Insert(source, (IEnumerable <string>)sourceHeader);
internal BlockEndOpcode() : base(OpcodeID.BlockEnd) { this.sourceJumps = new QueryBuffer<Opcode>(1); }