/// <summary> /// Generates a Kusto table for a specific <see cref="Type"/>, by mapping it's properties to columns. /// </summary> /// <param name="client">The <see cref="ICslAdminProvider"/> that we are extending.</param> /// <param name="type">The <see cref="Type"/> that we are generating a table for.</param> /// <returns>The name of the table created.</returns> public static string GenerateTableFromType(this ICslAdminProvider client, Type type) { var tableName = type.Name; var command = CslCommandGenerator.GenerateTableShowCommand(tableName); try { client.ExecuteControlCommand(command); return(tableName); } catch (KustoBadRequestException ex) when(ex.ErrorMessage.Contains("'Table' was not found")) { // soak } var columns = type.GetProperties().Select(property => new Tuple <string, string>(property.Name, property.PropertyType.FullName)).ToList(); command = CslCommandGenerator.GenerateTableCreateCommand(tableName, columns); client.ExecuteControlCommand(command); return(tableName); }