protected FunctionSchema GetFunctionSchemaFromRow(DataRow row) { FunctionSchema schema = new FunctionSchema { Name = row[FunctionOfName].ToString(), Definition = row[FunctionOfDefinition].ToString() }; return(schema); }
protected FunctionSchema GetFunctionSchemaFromRow(DataRow row) { FunctionSchema schema = new FunctionSchema { Name = row["ROUTINE_NAME"].ToString(), Definition = row["ROUTINE_DEFINITION"].ToString() }; return(schema); }
/// <summary> /// Delete a function from the file system /// </summary> /// <param name="functionSchema">The function to remove</param> /// <param name="rootFolder">The root folder for all the CSL files</param> public static void DeleteFromFolder(this FunctionSchema functionSchema, string rootFolder) { string funcFolder = Path.Combine(rootFolder, "Functions"); if (!string.IsNullOrEmpty(functionSchema.Folder)) { funcFolder = Path.Combine(funcFolder, functionSchema.Folder); } string destinationFile = Path.Combine(funcFolder, functionSchema.Name + ".csl"); File.Delete(destinationFile); }
public IList <FunctionSchema> LoadFunctionSchemaList() { List <FunctionSchema> functionSchemas = new List <FunctionSchema>(); DataTable info = this.ExecuteQuery(SQLForFunction); if (info.Rows.Count > 0) { foreach (DataRow row in info.Rows) { FunctionSchema schema = this.GetFunctionSchemaFromRow(row); functionSchemas.Add(schema); } } return(functionSchemas); }
public IList <FunctionSchema> LoadFunctionSchemaList() { List <FunctionSchema> functionSchemas = new List <FunctionSchema>(); DataTable info = this._connection.GetSchema("Procedures", new String[] { null, this.GetDataBaseName(), null, "FUNCTION" }); if (info.Rows.Count > 0) { foreach (DataRow row in info.Rows) { FunctionSchema schema = this.GetFunctionSchemaFromRow(row); functionSchemas.Add(schema); } } return(functionSchemas); }
/// <summary> /// Write the function to the file system. /// </summary> /// <param name="functionSchema">The function to write</param> /// <param name="rootFolder">The root folder for all the CSL files</param> /// <returns></returns> public static void WriteToFile(this FunctionSchema functionSchema, string rootFolder) { string filename = functionSchema.Name + ".csl"; // First remove any other files with this name. In the case where you moved an object to a new folder, this will handle cleaning up the old file string[] existingFiles = Directory.GetFiles(rootFolder, filename, SearchOption.AllDirectories); if (existingFiles.Length > 0) { foreach (string file in existingFiles) { try { File.Delete(file); } catch { // It's not the end of the world if this call fails } } } // Now add write the new file to the correct location. string funcFolder = Path.Combine(rootFolder, "Functions"); if (!string.IsNullOrEmpty(functionSchema.Folder)) { string cleanedFolder = string.Join("", functionSchema.Folder.Split(Path.GetInvalidPathChars())); funcFolder = Path.Combine(funcFolder, cleanedFolder); } string destinationFile = Path.Combine(funcFolder, filename); if (!Directory.Exists(funcFolder)) { Directory.CreateDirectory(funcFolder); } File.WriteAllText(destinationFile, CslCommandGenerator.GenerateCreateOrAlterFunctionCommand(functionSchema, true)); }
/// <summary> /// Remove the specified function /// </summary> /// <param name="functionSchema">The function to drop</param> public void DropFunction(FunctionSchema functionSchema) { _adminClient.ExecuteControlCommand(_databaseName, $".drop function ['{functionSchema.Name}']"); }
public KustoFunctionSchema(FunctionSchema value) => Value = value;
/// <summary> /// Delete a function from Kusto /// </summary> /// <param name="functionSchema">The function to remove</param> /// <param name="kustoQueryEngine">An initialized query engine for issuing the Kusto command</param> public static void DeleteFromKusto(this FunctionSchema functionSchema, QueryEngine kustoQueryEngine) { kustoQueryEngine.DropFunction(functionSchema); }
/// <summary> /// Write a function to Kusto /// </summary> /// <param name="functionSchema">The function to write</param> /// <param name="kustoQueryEngine">An initialized query engine for issuing the Kusto command</param> public static void WriteToKusto(this FunctionSchema functionSchema, QueryEngine kustoQueryEngine) { kustoQueryEngine.CreateOrAlterFunctionAsync(CslCommandGenerator.GenerateCreateOrAlterFunctionCommand(functionSchema, true), functionSchema.Name).Wait(); }
public static IKustoSchema AsKustoSchema(this FunctionSchema schema) => new KustoFunctionSchema(schema);