/// <summary> /// Excutes CommandText for read /// </summary> /// <param name="propList"> /// Optional:CSV of properies. limits number of Fileds that will be returned in result. it can /// increase performance. /// </param> /// <param name="queryConditions"> /// Optional: Limits rows by condition on fields. Default logic is AND. You can change it in /// Logic argument of this method /// </param> /// <param name="logic">The logic.</param> /// <returns>A collection of string in raw format of API result.</returns> public IEnumerable <string> ExecuteReader(string propList = null, MKCommandParameterCollection queryConditions = null, MKQueryLogicOperators logic = MKQueryLogicOperators.And) { verifyConnection(); if (!string.IsNullOrEmpty(propList)) { Parameters.Add(".proplist", propList); } //******************************************* if (CommandText.Contains(@"/where/")) { if (queryConditions == null) { queryConditions = new MKCommandParameterCollection(); } queryConditions.AddRange(getCommandTextQueries(CommandText)); } if (queryConditions != null) { foreach (var q in queryConditions) { q.Name = "?" + q.Name; Parameters.Add(q); } if (queryConditions.Count > 1) { switch (logic) { case MKQueryLogicOperators.And: Parameters.Add("?#", "&"); break; case MKQueryLogicOperators.Or: Parameters.Add("?#", "|"); break; } } } sendCommand(); var res = Connection.Read(); checkResponse(res); return(res); }
private void HandleTempTable() { if (!CommandText.Contains(SingleRowTempTableRequiredToken)) { return; } var commandText = CommandText; var tempFile = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(Connection.DataSource)), SingleRowTempTableName + ".dbf"); if (!File.Exists(tempFile)) { CommandText = "CREATE TABLE '" + tempFile + "' FREE (PK i)"; ExecuteNonQuery(); CommandText = "INSERT INTO '" + tempFile + "' VALUE(1)"; ExecuteNonQuery(); } CommandText = commandText.Replace(SingleRowTempTableRequiredToken, "'" + tempFile + "'"); }
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { /* * SchemaManager (and why here) explained: * * From what I can tell, the EF designer is only able to get schema information from querying data using the connection. This seemed to be * a problem because I couldn't figure a way to get all the required information from a DBC... plus, I really didn't want to require a DBC to use this * EF Provider. What I figured I could do instead was hook into the query process and use a combination of techniques to get the schema information * and write it to a temp table. Then rewrite the command text to include the temp table. * * The part of the query that needs to be rewritten comes from the DefiningQuery in StoreSchemaDefinition.ssdl. The DefiningQuery will have a token * that identifies the requested schema information. * * This was the only place that I found where I had an instance of the connection and the command... * */ if (SchemaManager.IsSchemaQuery(this.CommandText)) { DataTable dataTable = null; SchemaManager.Using(Connection.ConnectionString, (schemaManager) => dataTable = schemaManager.CreateDataTable(CommandText, Parameters)); return(dataTable.CreateDataReader()); } var hasExecuteScalar = CommandText.Contains(ExecuteScalarBeginDelimiter); HandleTempTable(); SplitMultipleCommands(); HandleExecuteScalar(); var reader = (VfpClient.VfpDataReader)base.ExecuteDbDataReader(behavior); if (hasExecuteScalar) { return(new VfpAutoIncDataReader(reader, CommandText)); } return(reader); }
void ValidateParameters(IEnumerable <DbParameter> parameters) { const string errmsg = "Issue found with parameter `{0}` on object `{1}`:{2}{2}{3}"; foreach (var p in parameters) { var n = p.ParameterName; Debug.Assert(n.Length >= 2, string.Format(errmsg, p, this, Environment.NewLine, "Parameters should always be 2 or more characters (one for the prefix, one or more for the name).")); Debug.Assert(n[0] == ParameterPrefixChar, string.Format(errmsg, p, this, Environment.NewLine, "Parameters should begin with the ParameterPrefix.")); Debug.Assert(n[1] != ParameterPrefixChar, string.Format(errmsg, p, this, Environment.NewLine, "The second character should not be the ParameterPrefix.")); Debug.Assert(CommandText.Contains(p.ParameterName), string.Format(errmsg, p, this, Environment.NewLine, "The parameter could not be found in the CommandText...")); } }