private static void WriteToFile(string folderPath, string nameSpace, bool keepDefaultValue, bool withUnderlinePrefix, MemberAccessPrivilege accessPrivilege, TableSchema tableSchema)
        {
            var fieldSchemaList = Mapper.Map<List<TableColumnSchema>, List<Field>>(tableSchema);
            var propertySchemaList = Mapper.Map<List<TableColumnSchema>, List<Property>>(tableSchema);
            var model = Mapper.Map<TableSchema, Model>(tableSchema);

            // update flag to decide keeping default value or not
            fieldSchemaList.Each(field => field.KeepDefaultValue = keepDefaultValue);
            // update flag for nameing rule -- underline prefix
            fieldSchemaList.Each(field => field.WithUnderlinePrefixNamingRule = withUnderlinePrefix);

            model.Namespace = nameSpace;
            model.AccessPrivilege = accessPrivilege;
            model.AddRange(fieldSchemaList);
            model.AddRange(propertySchemaList);

            var code = model.Serialize();

            using (FileStream stream = new FileStream(Path.Combine(folderPath, model.ModelName + ".cs"), FileMode.OpenOrCreate))
            using (var writer = new StreamWriter(stream, System.Text.Encoding.UTF8))
            {
                stream.SetLength(0);
                writer.Write(code);
                writer.Flush();
                writer.Close();
            }
        }
Exemplo n.º 2
0
        public static void RunTableTemplate(CodeTemplate Parent, TableSchema SourceTable, string Path, string Template, string Output, bool debug)
        {
            // admin datamodel
            try
            {

                PreserveRegionsMergeStrategy strategy = new PreserveRegionsMergeStrategy("^[ \t]*(?i:Custom)", "C#");
                CodeTemplate template = null;
                if (!debug)
                {
                    template = Parent.GetCodeTemplateInstance(Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }
                else
                {
                    template = CompileTemplate(Parent, Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }

                if (template != null)
                {
                    template.SetProperty("SourceTable", SourceTable);
                    template.RenderToFile(Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Output, strategy);
                    Parent.Response.WriteLine("File: " + Output + " Created Successfully");
                }
                else
                {
                    Parent.Response.WriteLine("Template is null: " + Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                }
            }
            catch (Exception ex)
            {
                Parent.Response.WriteLine("Template: " + Parent.CodeTemplateInfo.DirectoryName + Path + "\\" + Template);
                Parent.Response.WriteLine("Error: " + ex.Message);
                Parent.Response.WriteLine("StackTrace: " + ex.StackTrace);
            }
        }
Exemplo n.º 3
0
		public override void EndTableLoad(IDbConnection connection, TableSchema table)
		{
			foreach (var column in table.Columns)
			{
				// Update sequence to make sure that next generated value
				// will not cause a constraint violation.
				//
				if (!column.AutoIncrement)
					continue;
				using (var cmd = connection.CreateCommand())
				{
					cmd.CommandText = @"SELECT MAX(" + MakeDdlElementName(column.Name) +
						@") FROM " + MakeDdlElementName(table.Name);
					cmd.CommandTimeout = 0;

					var maxValue = Convert.ToInt32(cmd.ExecuteScalar());

					if (maxValue <= 0)
						continue;
					var genName = ParseName(_generatorPrefix, table.Name, column.Name);

					var dbsmGenerator = new DBGenerator {Name = genName, StartValue = maxValue};

					cmd.CommandText = MakeDdlGeneratorSet(dbsmGenerator);
					cmd.ExecuteNonQuery();
				}
			}

			base.EndTableLoad(connection, table);
		}
Exemplo n.º 4
0
 public static bool IsManyToManyTable(TableSchema table)
 {
     return (table.Columns.Count == 2 &&
         table.HasPrimaryKey() &&
         table.PrimaryKeyColumns().Count == 2 &&
         table.InReferences.Count == 2);
 }
		public override TableSchemaCollection GetTables ()
		{
			TableSchemaCollection tables = new TableSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			// Tables need to be ordered bacause TableSchemaCollection is "created" as sorted by default.
			IDbCommand command = conn.CreateCommand (
				"SELECT name, sql FROM sqlite_master WHERE type = 'table' ORDER BY name"
			);
			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader()) {
						while (r.Read ()) {
							TableSchema table = new TableSchema (this);
		
							table.SchemaName = "main";
							table.Name = r.GetString (0);
							table.IsSystemTable = table.Name.StartsWith ("sqlite_");
							table.Definition = r.GetString (1);
							
							tables.Add (table);
						}
						r.Close ();
					}
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();

			return tables;
		}
        public DbSchema GetSchema()
        {
            var schema = new DbSchema();
            var map = _configuration.BuildMapping();
            var mappings = _configuration.ClassMappings;

            foreach(var class_map in mappings)
            {
                var table = class_map.Table;
                var table_schema = new TableSchema() {TableName = table.Name, SchemaName = table.Schema};
                foreach (var column in table.ColumnIterator)
                {

                    var type_code = column.GetSqlTypeCode(map);

                    var columnSchema = new ColumnSchema()
                                           {
                                               TableName = table_schema.TableName,
                                               ColumnName = column.Name,
                                               IsNullable = column.IsNullable,
                                               DatabaseType = type_code.DbType,
                                               Size = column.Length,
                                               Scale = column.Scale,
                                               Precision = column.Precision,
                                               IsPrimaryKey = table.PrimaryKey.Columns.Contains(column)
                                           };

                    // columnSchema.DatabaseType = property.GetSqlTypeCode(map).DbType;
                    table_schema.AddColumn(columnSchema);
                }
                schema.AddTable(table_schema);
            }
            return schema;
        }
Exemplo n.º 7
0
		public bool ShowTableEditorDialog (IEditSchemaProvider schemaProvider, TableSchema table, bool create)
		{
			TableEditorSettings settings = new TableEditorSettings ();
			TableEditorDialog dlg = new TableEditorDialog (schemaProvider, create, settings);
			dlg.Initialize (table);

			return RunDialog (dlg);
		public bool ShowTableEditorDialog (IEditSchemaProvider schemaProvider, TableSchema table, bool create)
		{
			TableEditorSettings settings = new TableEditorSettings ();
			settings.ConstraintSettings.CheckSettings.SupportsColumnConstraints = false;
			TableEditorDialog dlg = new TableEditorDialog (schemaProvider, create, settings);
			dlg.Initialize (table);
			return RunDialog (dlg);
Exemplo n.º 9
0
Arquivo: Join.cs Projeto: eleooo/App
 /// <summary>
 /// Initializes a new instance of the <see cref="Join"/> class.
 /// </summary>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 /// <param name="joinType">Type of the join.</param>
 public Join(TableSchema.TableColumn from, TableSchema.TableColumn to, JoinType joinType,params string[] joinExpressions)
 {
     FromColumn = from;
     ToColumn = to;
     Type = joinType;
     if (joinExpressions != null && joinExpressions.Length > 0)
         JoinExpressions.AddRange(joinExpressions);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Helper to generate class name from a table
 /// </summary>
 /// <param name="table"></param>
 /// <param name="prefix"></param>
 /// <param name="strip"></param>
 /// <returns>string</returns>
 public static string GetClassNameFromTable(TableSchema table, string prefix, string postfix, string strip)
 {
     if (strip != string.Empty)
     {
         return prefix + table.Name.Replace(strip, "").ToCSharpIdentifier().ToPascalCase() + postfix;
     }
     else
     {
         return prefix + table.Name.ToCSharpIdentifier().ToPascalCase() + postfix;
     }
 }
Exemplo n.º 11
0
		public override void EndTableLoad(IDbConnection connection, TableSchema table)
		{
			if (TableHasIdentityColumns(table))
				using (var cmd = connection.CreateCommand())
				{
					cmd.CommandText = @"SET IDENTITY_INSERT " + MakeDdlElementName(table.Name) + @" OFF";
					cmd.ExecuteNonQuery();
				}

			base.EndTableLoad(connection, table);
		}
Exemplo n.º 12
0
        static RelationParsingTest()
        {
            NumbersSchema = new TableSchema("Numbers");
            PowersSchema = new TableSchema("Powers");

            NumbersSchema.Columns.AddValueColumn("Number", typeof(int), 0);
            NumbersSchema.Columns.AddValueColumn("IsEven", typeof(bool), false);

            PowersKeyColumn = PowersSchema.Columns.AddForeignKey("Number", NumbersSchema, "Powers");

            PowersSchema.Columns.AddValueColumn("Exponent", typeof(int), 0);
            PowersSchema.Columns.AddValueColumn("Value", typeof(int), 0);
        }
Exemplo n.º 13
0
		private static List<TableSchema> GetTables(SqlConnection con)
		{
			var tables = new List<TableSchema>();
			string[] restrict4 = {null, null, null, "TABLE"};
			string[] restrict3 = {null, null, null};

			var dtTables = SqlSchemaFactory.GetSchema(con, "Tables", restrict4);
			for (var i = 0; i < dtTables.Rows.Count; i++)
			{
				var tRow = dtTables.Rows[i];
				var eTable = new TableSchema {Name = tRow["TABLE_NAME"].ToString()};
				// Columns
				restrict3[0] = null;
				restrict3[1] = null;
				restrict3[2] = eTable.Name;

				var dtShema = SqlSchemaFactory.GetSchema(con, "Columns", restrict3);
				if (dtShema.Rows.Count > 0)
				{
					eTable.Columns = new TableColumnSchema[dtShema.Rows.Count];

					for (var j = 0; j < dtShema.Rows.Count; j++)
					{
						var cRow = dtShema.Rows[j];

						var eColumn = new TableColumnSchema
						{
							Name = cRow["COLUMN_NAME"].ToString(),
							Size = Convert.ToInt32(cRow["COLUMN_SIZE"], CultureInfo.InvariantCulture),
							Type = TypeSqlToDbsm(cRow["COLUMN_DATA_TYPE"].ToString()),
							Nullable = Convert.ToBoolean(cRow["IS_NULLABLE"], CultureInfo.InvariantCulture),
							DefaultValue = cRow["COLUMN_DEFAULT"].ToString(),
							Increment = Convert.ToInt32(cRow["IDENTITY_INCREMENT"], CultureInfo.InvariantCulture),
							Seed = Convert.ToInt32(cRow["IDENTITY_SEED"], CultureInfo.InvariantCulture),
							AutoIncrement = Convert.ToBoolean(cRow["IS_IDENTITY"], CultureInfo.InvariantCulture),
							DecimalPrecision = Convert.ToInt32(cRow["NUMERIC_PRECISION"], CultureInfo.InvariantCulture),
							DecimalScale = Convert.ToInt32(cRow["NUMERIC_SCALE"], CultureInfo.InvariantCulture)
						};
						eColumn.DefaultValue = string.IsNullOrEmpty(eColumn.DefaultValue)
												? null
												: UnBracket.ParseUnBracket(eColumn.DefaultValue);

						eTable.Columns[j] = eColumn;
					}
				}

				tables.Add(eTable);
			}
			return tables;
		}
Exemplo n.º 14
0
 public static bool IsChildFKColumn(ColumnSchema column, TableSchema table)
 {
     foreach (ReferenceSchema inReference in table.InReferences)
     {
         foreach (ReferenceJoin join in inReference.Joins)
         {
             //Found the child Column...
             if (join.ChildColumn.ObjectID == column.ObjectID)
             {
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 15
0
		private static List<TableSchema> GetTables(FbConnection con)
		{
			string[] restrict3 = {null, null, null};
			string[] restrict4 = {null, null, null, null};
			var aStore = new List<TableSchema>();

			restrict4[0] = null;
			restrict4[1] = null;
			restrict4[2] = null;
			restrict4[3] = "TABLE";
			var dtTables = con.GetSchema("Tables", restrict4);
			for (var i = 0; i < dtTables.Rows.Count; i++)
			{
				var tRow = dtTables.Rows[i];
				var eTable = new TableSchema {Name = tRow["TABLE_NAME"].ToString()};
				// Columns
				restrict3[0] = null;
				restrict3[1] = null;
				restrict3[2] = eTable.Name;
				var dtShema = con.GetSchema("Columns", restrict3);
				if (dtShema.Rows.Count > 0)
					eTable.Columns = new TableColumnSchema[dtShema.Rows.Count];
				for (var j = 0; j < dtShema.Rows.Count; j++)
				{
					var cRow = dtShema.Rows[j];

					var eColumn = new TableColumnSchema
									{
									Name = cRow["COLUMN_NAME"].ToString(),
									Size = Convert.ToInt32(cRow["COLUMN_SIZE"], CultureInfo.InvariantCulture),
									Type = TypeFbToDbsm(cRow["COLUMN_DATA_TYPE"].ToString()),
									Nullable = Convert.ToBoolean(cRow["IS_NULLABLE"], CultureInfo.InvariantCulture)
									};
					eColumn.DefaultValue = HelpDbscColumnDefault(con, eColumn.Name, eTable.Name);
					eColumn.DefaultValue = string.IsNullOrEmpty(eColumn.DefaultValue) ? null : eColumn.DefaultValue;
					eColumn.DecimalPrecision = cRow["NUMERIC_PRECISION"] == DBNull.Value
												? 0
												: Convert.ToInt32(cRow["NUMERIC_PRECISION"], CultureInfo.InvariantCulture);
					eColumn.DecimalScale = Convert.ToInt32(cRow["NUMERIC_SCALE"], CultureInfo.InvariantCulture);

					eTable.Columns[j] = eColumn;
				}
				aStore.Add(eTable);
			}
			return aStore;
		}
 public override TableSchemaCollection GetTables()
 {
     TableSchemaCollection tables = new TableSchemaCollection ();
     Console.WriteLine("getTables");
     using (IPooledDbConnection conn = connectionPool.Request ()) {
         Console.WriteLine("conn:"+conn.ToString());
         MongoDbConnection connection = (MongoDbConnection) conn.DbConnection;
         Console.WriteLine("connection:"+connection.ToString());
         foreach(string colName in connection.getCollections()){
             TableSchema col = new TableSchema(this);
             Console.WriteLine("table add:"+colName);
             col.Name = colName;
             tables.Add(col);
         }
     }
     return tables;
 }
Exemplo n.º 17
0
        public void SimpleColumnTest()
        {
            var schema = new TableSchema("SimpleColumnTest");

            schema.Columns.AddValueColumn("Col1", typeof(int), 5);
            schema.Columns.AddValueColumn("Col2", typeof(int), 5);
            schema.Columns.AddValueColumn("Col3", typeof(int), 5);
            schema.Columns.AddValueColumn("Col4", typeof(int), 5);

            Expression<Func<Row, object>> func = r =>
                r["Col1"].ToString() + ((int)r["Col2"] % r.Field<int?>("Col3")) + r["Col4"];
            var dep = DependencyParser.GetDependencyTree(schema, func);
            Assert.IsFalse(dep.RequiresDataContext);
            Assert.IsInstanceOfType(dep, typeof(SameRowDependency));

            var srd = (SameRowDependency)dep;
            Assert.IsTrue(schema.Columns.SequenceEqual(srd.DependentColumns.OrderBy(c => c.Name)));
        }
Exemplo n.º 18
0
        public static int GenerateRows(StreamWriter writer, TableSchema schema, Locator where, bool hasIfExists)
        {
            TableName tableName = schema.TableName;
            string sql = string.Format("SELECT * FROM {0}", tableName);
            if (where != null)
                sql = string.Format("SELECT * FROM {0} WHERE {1}", tableName, where);

            SqlCmd cmd = new SqlCmd(tableName.Provider, sql);
            TableClause script = new TableClause(schema);

            int count = 0;
            cmd.Read(
                reader =>
                {
                    DataTable schema1 = reader.GetSchemaTable();

                    string[] columns = schema1.AsEnumerable().Select(row => row.Field<string>("ColumnName")).ToArray();
                    object[] values = new object[columns.Length];

                    while (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            reader.GetValues(values);
                            if (hasIfExists)
                                writer.WriteLine(script.IF_NOT_EXISTS_INSERT(columns, values));
                            else
                                writer.WriteLine(script.INSERT(columns, values));

                            count++;
                            if (count % 5000 == 0)
                                writer.WriteLine(TableClause.GO);

                        }
                        reader.NextResult();
                    }
                });

            if (count != 0)
                writer.WriteLine(TableClause.GO);

            return count;
        }
Exemplo n.º 19
0
        public static string DatabaseDifference(CompareSideType sideType, DatabaseName dname1, DatabaseName dname2, string[] excludedTables)
        {
            TableName[] names = dname1.GetDependencyTableNames();
            excludedTables = excludedTables.Select(row => row.ToUpper()).ToArray();

            StringBuilder builder = new StringBuilder();
            foreach (TableName tableName in names)
            {
                TableName tname1 = tableName;
                TableName tname2 = new TableName(dname2, tableName.SchemaName, tableName.Name);

                TableSchema schema1 = new TableSchema(tname1);
                TableSchema schema2 = new TableSchema(tname2);

                Console.WriteLine(tname1.ShortName);

                if (excludedTables.Contains(tableName.ShortName.ToUpper()))
                {
                    Console.WriteLine("skip to compare data on excluded table {0}", tableName.ShortName);
                    continue;
                }

                if (schema1.PrimaryKeys.Length == 0)
                {
                    Console.WriteLine("undefined primary key");
                    continue;
                }

                if (tname2.Exists())
                {
                    builder.Append(TableDifference(sideType, schema1, schema2, schema1.PrimaryKeys.Keys, new string[] { }));
                }
                else
                {
                    builder.Append(Compare.GenerateRows(schema1, new TableReader(tname1)));
                }

                builder.AppendLine();
            }

            return builder.ToString();
        }
Exemplo n.º 20
0
		public override TableSchemaCollection GetTables ()
		{
			TableSchemaCollection tables = new TableSchemaCollection ();
			using (IPooledDbConnection conn = connectionPool.Request ()) {
				using (IDbCommand command = conn.CreateCommand (
					@"SELECT DISTINCT 
						c.relname, 
						n.nspname, 
						u.usename
					FROM 
						pg_class c, 
						pg_namespace n, 
						pg_user u
					WHERE 	
						c.relnamespace = n.oid
						AND c.relowner = u.usesysid
						AND c.relkind='r' 
						AND NOT EXISTS
							(SELECT 1 FROM pg_rewrite r WHERE r.ev_class = c.oid AND r.ev_type = '1')
					ORDER BY relname;")) {
					try {
						using (IDataReader r = command.ExecuteReader()) {
							while (r.Read ()) {
								TableSchema table = new TableSchema (this);
								table.Name = r.GetString (0);
								table.IsSystemTable = table.Name.StartsWith ("pg_") || table.Name.StartsWith ("sql_");
								table.SchemaName = r.GetString (1);
								table.OwnerName = r.GetString (2);
								// TODO: Fill table.Definition
								tables.Add (table);
							}
							r.Close ();
						}
					} catch (Exception e) {
						QueryService.RaiseException (e);
					} finally {
						conn.Release ();
					}
				}
			}
			return tables;
Exemplo n.º 21
0
	public string GetModelClassName(TableSchema table)
	{
		string result;
		if ( table.ExtendedProperties.Contains("ModelName") )
		{
			result = (string)table.ExtendedProperties["ModelName"].Value;	
			return MakePascal(result);
		}
	
		if (table.Name.EndsWith("s"))
		{
			result = MakeSingle(table.Name);
		}
		else
		{
			result = table.Name;
		}
	
		return MakePascal(result);
	}
Exemplo n.º 22
0
        internal static dynamic DeserializeDynamic(TableSchema schema, TableRow row)
        {
            if (row.F.Count == 1 && DataTypeUtility.Parse(schema.Fields[0].Type) != DataType.Record)
            {
                var field = schema.Fields[0];
                var value = row.F[0].V;
                var parsedValue = Parse(field.Type, (string)value);

                return parsedValue;
            }

            IDictionary<string, object> container = new ExpandoObject();
            for (int i = 0; i < row.F.Count; i++)
            {
                var field = schema.Fields[i];
                var value = row.F[i].V;
                var parsedValue = Parse(field.Type, (string)value);

                container.Add(field.Name, parsedValue);
            }
            return container;
        }
Exemplo n.º 23
0
 /// <summary>
 /// Gets all of the columns for a table.
 /// </summary>
 /// <param name="table"></param>
 /// <returns></returns>
 public virtual ColumnSchemaList GetColumnSchemas(TableSchema table)
 {
     IDictionary<string, string> constraints = GetConstraints(table.Name);
     string tableName = table.Name;
     ColumnSchemaList result = null;
     string cmdtext = @"
     select
     case when c.autoinc_next is null then 0 else 1 end is_identity,
     c.*
     from information_schema.columns c
     where c.table_name = @table_name
     ";
     using (SqlCeCommand cmd = new SqlCeCommand(cmdtext))
     {
         cmd.Parameters.Add("@table_name", SqlDbType.NVarChar, 128).Value = tableName;
         using (IDataReader reader = _helper.ExecuteReader(cmd))
         {
             while (reader.Read())
             {
                 if (result == null) result = new ColumnSchemaList();
                 SqlDbType sqlType = getSqlDbType(reader["DATA_TYPE"].ToString());
                 Type dataType = getDataType(reader["DATA_TYPE"].ToString());
                 string name = reader["COLUMN_NAME"].ToString();
                 int length = reader["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value ? System.Convert.ToInt32(reader["CHARACTER_MAXIMUM_LENGTH"]) : -1;
                 Dictionary<string, object> props = new Dictionary<string, object>();
                 props.Add("is_identity", Convert.ToBoolean(reader["is_identity"]));
                 props.Add("is_nullable", (reader["is_nullable"].ToString().Equals("YES")));
                 props.Add("is_computed", false);
                 props.Add("is_primary_key", constraints.ContainsKey(name) && constraints[name] == "PRIMARY KEY");
                 props.Add("is_foreign_key", constraints.ContainsKey(name) && constraints[name] == "FOREIGN KEY");
                 props.Add("formula", "");
                 result.Add(new ColumnSchema(this, table, sqlType, dataType, name, length, props));
             }
         }
     }
     return result;
 }
 /// <summary>
 /// Uploads a stream of JSON data to a table.
 /// This method just creates a <see cref="TableReference"/> and delegates to <see cref="BigQueryClient.UploadJson(TableReference, TableSchema, Stream, UploadJsonOptions)"/>.
 /// </summary>
 /// <param name="tableId">The table ID. Must not be null.</param>
 /// <param name="schema">The schema of the data. May be null if the table already exists, in which case the table schema will be fetched and used.</param>
 /// <param name="input">The stream of input data. Must not be null.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>A data upload job.</returns>
 public BigQueryJob UploadJson(string tableId, TableSchema schema, Stream input, UploadJsonOptions options = null) =>
 _client.UploadJson(GetTableReference(tableId), schema, input, options);
Exemplo n.º 25
0
 /// <summary>
 /// Asynchronously creates a job to load data from a Google Cloud Storage file to a BigQuery table.
 /// This method creates a single-element array and delegates to <see cref="CreateLoadJobAsync(IEnumerable{String}, TableReference, TableSchema, CreateLoadJobOptions, CancellationToken)"/>.
 /// </summary>
 /// <remarks>
 /// To avoid confusion between source and destination tables, overloads are not provided that take the
 /// individual components of table references. Instead, use <see cref="GetTableReference(string, string)"/> or
 /// <see cref="GetTableReference(string, string, string)"/> to create table references.
 /// </remarks>
 /// <param name="sourceUri">The Google Cloud Storage URI of the file to load. Must not be null.</param>
 /// <param name="destination">The destination table to write data to. Must not be null.</param>
 /// <param name="schema">The schema for the table. May be null if the load operation does not require a schema,
 /// such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if
 /// the options are set to autodetect the schema.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is the job created for the load operation.</returns>
 public virtual Task <BigQueryJob> CreateLoadJobAsync(string sourceUri, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null, CancellationToken cancellationToken = default)
 => CreateLoadJobAsync(new[] { GaxPreconditions.CheckNotNull(sourceUri, nameof(sourceUri)) }, destination, schema, options, cancellationToken);
 /// <inheritdoc />
 public override Task <BigQueryJob> UploadJsonAsync(TableReference tableReference, TableSchema schema, IEnumerable <string> rows,
                                                    UploadJsonOptions options = null, CancellationToken cancellationToken = default)
 => UploadJsonAsync(tableReference, schema, CreateJsonStream(rows), options, cancellationToken);
        /// <inheritdoc />
        public override async Task <BigQueryJob> UploadJsonAsync(TableReference tableReference, TableSchema schema, Stream input,
                                                                 UploadJsonOptions options = null, CancellationToken cancellationToken = default)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? (options?.Autodetect == true ? null : await GetSchemaAsync(tableReference, cancellationToken).ConfigureAwait(false));

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat     = "NEWLINE_DELIMITED_JSON",
                Schema           = schema
            };

            options?.ModifyConfiguration(configuration);

            return(await UploadDataAsync(configuration, input, "text/json", options, cancellationToken).ConfigureAwait(false));
        }
 /// <inheritdoc />
 public override BigQueryJob UploadJson(TableReference tableReference, TableSchema schema, IEnumerable <string> rows, UploadJsonOptions options = null)
 => UploadJson(tableReference, schema, CreateJsonStream(rows), options);
        /// <inheritdoc />
        public override async Task <BigQueryJob> UploadAvroAsync(TableReference tableReference, TableSchema schema, Stream input, UploadAvroOptions options = null, CancellationToken cancellationToken = default)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat     = "AVRO"
            };

            options?.ModifyConfiguration(configuration);

            return(await UploadDataAsync(configuration, input, "application/vnd.apache.avro+binary", options, cancellationToken).ConfigureAwait(false));
        }
    public static List <SearchCriteria> GetIndexSearchCriteria(TableSchema table, string extendedProperty)
    {
        TableSearchCriteria tsc = new TableSearchCriteria(table, extendedProperty);

        return(tsc.GetIndexSearchCriteria());
    }
Exemplo n.º 31
0
 /// <inheritdoc />
 public abstract string MakeCreateTempTableStatement(TableSchema tableSchema);
Exemplo n.º 32
0
 /// <inheritdoc />
 public abstract string MakeDropTempTableStatement(TableSchema tableSchema);
Exemplo n.º 33
0
 /// <inheritdoc />
 public abstract string MakeGetPageStatement(TableSchema tableSchema, Page page, string conditions, string orderBy);
Exemplo n.º 34
0
 /// <inheritdoc />
 public abstract string MakeInsertReturningIdentityStatement(TableSchema tableSchema);
    public static List <SearchCriteria> GetIndexSearchCriteria(TableSchema table)
    {
        TableSearchCriteria tsc = new TableSearchCriteria(table);

        return(tsc.GetIndexSearchCriteria());
    }
        /// <inheritdoc />
        public override PagedEnumerable <TableDataList, BigQueryRow> ListRows(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            schema = schema ?? GetSchema(tableReference);

            var pageManager = new TableRowPageManager(this, schema);

            return(new RestPagedEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       () => CreateListRequest(tableReference, options), pageManager));
        }
 public TableSearchCriteria(TableSchema sourceTable, string extendedProperty) : this(sourceTable)
 {
     this.extendedProperty = extendedProperty;
 }
 public TableSearchCriteria(TableSchema sourceTable)
 {
     this.table = sourceTable;
 }
Exemplo n.º 39
0
 public bool ShowTableEditorDialog(IEditSchemaProvider schemaProvider, TableSchema table, bool create)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 40
0
 public abstract string MakeGetTopNStatement(TableSchema tableSchema, int take, string conditions, string orderBy);
Exemplo n.º 41
0
        /// <summary>
        /// Generates a property to get a parent row.
        /// </summary>
        /// <param name="keyrefSchema">The foreign key that references the parent table.</param>
        public TableVoidConstructor(TableSchema tableSchema)
        {
            // Construct the type names for the table and rows within the table.
            string rowTypeName = string.Format("{0}Row", tableSchema.Name);

            //			/// <summary>
            //			/// Creates the Department table.
            //			/// </summary>
            //			internal DepartmentDataTable() :
            //					base("Department")
            //			{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement(string.Format("Creates the {0} table.", tableSchema.Name), true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Attributes = MemberAttributes.Assembly;
            this.BaseConstructorArgs.Add(new CodePrimitiveExpression(tableSchema.Name));

            // Initialize the 'IsPersistent' property.
            // e.g.				this.IsPersistent = false;
            if (tableSchema.IsPersistent)
            {
                this.Statements.Add(new CodeCommentStatement("This indicates that the table should not be saved to the durable storage."));
                this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "IsPersistent"), new CodePrimitiveExpression(tableSchema.IsPersistent)));
            }

            //				// The DepartmentId Column
            //				this.columnDepartmentId = new Column("DepartmentId", typeof(int));
            //				this.columnDepartmentId.AllowDBNull = false;
            //				this.Columns.Add(this.columnDepartmentId);
            foreach (ColumnSchema columnSchema in tableSchema.Columns)
            {
                if (columnSchema.DeclaringType == tableSchema.TypeSchema)
                {
                    // Create the column using the datatype specified in the schema.
                    this.Statements.Add(new CodeCommentStatement(string.Format("The {0} Column", columnSchema.Name)));
                    CodeExpression right = new CodeObjectCreateExpression("Column", new CodeExpression[] { new CodePrimitiveExpression(columnSchema.Name), new CodeTypeOfExpression(columnSchema.DataType) });
                    this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), right));

                    // Persistent property
                    if (tableSchema.IsPersistent)
                    {
                        this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "IsPersistent"), new CodePrimitiveExpression(columnSchema.IsPersistent)));
                    }

                    // AutoIncrement, AutoIncrementSeed and AutoIncrementStep Properties.
                    if (columnSchema.IsAutoIncrement)
                    {
                        this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "AutoIncrement"), new CodePrimitiveExpression(true)));
                        if (columnSchema.AutoIncrementSeed > 0)
                        {
                            this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "AutoIncrementSeed"), new CodePrimitiveExpression(columnSchema.AutoIncrementSeed)));
                        }
                        if (columnSchema.AutoIncrementStep > 1)
                        {
                            this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "AutoIncrementStep"), new CodePrimitiveExpression(columnSchema.AutoIncrementStep)));
                        }
                    }

                    // AllowDBNull Column property
                    if (columnSchema.MinOccurs == 1)
                    {
                        this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "AllowDBNull"), new CodePrimitiveExpression(false)));
                    }

                    // The default value exists as a string in the Xml Schema.  It must be stronly typed before being inserted into
                    // the target code. Unfortunately, the type information for the destination column is needed to convert the
                    // value properly.
                    if (columnSchema.MinOccurs == 0 && columnSchema.DefaultValue != null)
                    {
                        this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)), "DefaultValue"), new CodePrimitiveExpression(columnSchema.DefaultValue)));
                    }

                    // This will add the column created above to the table.
                    this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "Columns"), "Add", new CodeExpression[] { new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)) }));
                }
            }

            //				// The DepartmentKey Index
            //				this.indexDepartmentKey = new DepartmentKeyIndex("DepartmentKey", new Column[] {
            //							this.columnDepartmentId});
            //				this.Constraints.Add(this.indexDepartmentKey);
            //              this.Constraints.Add(new UniqueConstraint(new Column[] { this.columnObjectId }));
            foreach (ConstraintSchema constraintSchema in tableSchema.Keys)
            {
                this.Statements.Add(new CodeCommentStatement(string.Format("The {0} Index", constraintSchema.Name)));
                string indexVariableName         = string.Format("index{0}", constraintSchema.Name);
                List <CodeExpression> keyColumns = new List <CodeExpression>();
                foreach (ColumnSchema columnSchema in constraintSchema.Fields)
                {
                    keyColumns.Add(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), string.Format("column{0}", columnSchema.Name)));
                }
                this.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), indexVariableName),
                                                            new CodeObjectCreateExpression(new CodeTypeReference(string.Format("{0}Index", constraintSchema.Name)), new CodeArrayCreateExpression(new CodeTypeReference("Column"),
                                                                                                                                                                                                  keyColumns.ToArray()))));
                if (!constraintSchema.IsNullable && !constraintSchema.IsPrimaryKey)
                {
                    this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "Constraints"), "Add",
                                                                       new CodeObjectCreateExpression(new CodeTypeReference(typeof(System.Data.UniqueConstraint)), new CodeArrayCreateExpression(new CodeTypeReference("Column"),
                                                                                                                                                                                                 keyColumns.ToArray()))));
                }
            }

            //			}
        }
Exemplo n.º 42
0
        private InsertRequest CreateLoadJobRequest(IEnumerable <string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options)
        {
            GaxPreconditions.CheckNotNull(sourceUris, nameof(sourceUris));
            GaxPreconditions.CheckNotNull(destination, nameof(destination));
            List <string> sourceList = sourceUris.ToList();

            GaxPreconditions.CheckArgument(sourceList.Count != 0, nameof(sourceUris), "Source URIs collection cannot be empty");

            var load = new JobConfigurationLoad {
                SourceUris = sourceList, DestinationTable = destination, Schema = schema
            };

            options?.ModifyRequest(load);
            var request = CreateInsertJobRequest(new JobConfiguration {
                Load = load
            }, options);

            return(request);
        }
Exemplo n.º 43
0
 /// <summary>
 /// Creates a job to load data from at least one Google Cloud Storage file to a BigQuery table.
 /// </summary>
 /// <remarks>
 /// To avoid confusion between source and destination tables, overloads are not provided that take the
 /// individual components of table references. Instead, use <see cref="GetTableReference(string, string)"/> or
 /// <see cref="GetTableReference(string, string, string)"/> to create table references.
 /// </remarks>
 /// <param name="sourceUris">The Google Cloud Storage URIs of the files to load. Must not be null or empty.</param>
 /// <param name="destination">The destination table to write data to. Must not be null.</param>
 /// <param name="schema">The schema for the table. May be null if the load operation does not require a schema,
 /// such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if
 /// the options are set to autodetect the schema.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The job created for the load operation.</returns>
 public virtual BigQueryJob CreateLoadJob(IEnumerable <string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 44
0
 /// <summary>
 /// Asynchronously creates a job to load data from at least one Google Cloud Storage file to a BigQuery table.
 /// </summary>
 /// <remarks>
 /// To avoid confusion between source and destination tables, overloads are not provided that take the
 /// individual components of table references. Instead, use <see cref="GetTableReference(string, string)"/> or
 /// <see cref="GetTableReference(string, string, string)"/> to create table references.
 /// </remarks>
 /// <param name="sourceUris">The Google Cloud Storage URIs of the files to load. Must not be null or empty.</param>
 /// <param name="destination">The destination table to write data to. Must not be null.</param>
 /// <param name="schema">The schema for the table. May be null if the load operation does not require a schema,
 /// such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if
 /// the options are set to autodetect the schema.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is the job created for the load operation.</returns>
 public virtual Task <BigQueryJob> CreateLoadJobAsync(IEnumerable <string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 45
0
 /// <summary>
 /// Creates a job to load data from a Google Cloud Storage file to a BigQuery table.
 /// This method creates a single-element array and delegates to <see cref="CreateLoadJob(IEnumerable{String}, TableReference, TableSchema, CreateLoadJobOptions)"/>.
 /// </summary>
 /// <remarks>
 /// To avoid confusion between source and destination tables, overloads are not provided that take the
 /// individual components of table references. Instead, use <see cref="GetTableReference(string, string)"/> or
 /// <see cref="GetTableReference(string, string, string)"/> to create table references.
 /// </remarks>
 /// <param name="sourceUri">The Google Cloud Storage URI of the file to load. Must not be null.</param>
 /// <param name="destination">The destination table to write data to. Must not be null.</param>
 /// <param name="schema">The schema for the table. May be null if the load operation does not require a schema,
 /// such as if the table already exists, the data is being loaded from a Google Cloud Datastore backup, or if
 /// the options are set to autodetect the schema.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The job created for the load operation.</returns>
 public virtual BigQueryJob CreateLoadJob(string sourceUri, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null)
 => CreateLoadJob(new[] { GaxPreconditions.CheckNotNull(sourceUri, nameof(sourceUri)) }, destination, schema, options);
 protected abstract string GetNullableDataType(TableSchema column);
        public ColumnSchema[] GetTableColumns(string connectionString, TableSchema table)
        {
            DataTable dt = GetSchemaData(connectionString,
                Columns,
                null /*restrictions[0] - catalog*/,
                null /*restrictions[1] - unused*/,
                table.Name /*restrictions[2] - table*/,
                null /*restrictions[3] - column*/);

            ColumnSchema[] columns = new ColumnSchema[dt.Rows.Count];
            int colIdx = 0;

            foreach (DataRow dr in dt.Rows)
            {
                ColumnSchema col = new ColumnSchema(table,
                    (String)dr[ColumnsNameColumn],
                    DbTypeFromType((String)dr[ColumnsTypeColumn]),
                    NativeTypeFromType((String)dr[ColumnsTypeColumn]),
                    0,
                    0,
                    0,
                    (bool)dr[ColumnsNullableColumn]
                    );

                columns[colIdx++] = col;
            }

            return columns;
        }
Exemplo n.º 48
0
 /// <inheritdoc />
 public override string MakeDropTempTableStatement(TableSchema tableSchema)
 {
     return("DROP TABLE " + tableSchema.Name);
 }
        public IndexSchema[] GetTableIndexes(string connectionString, TableSchema table)
        {
            DataTable dt = GetSchemaData(connectionString,
                Indexes,
                null /*restrictions[0] - catalog*/,
                null /*restrictions[1] - unused*/,
                table.Name /*restrictions[2] - table*/,
                null /*restrictions[3] - unused*/,
                null /*restrictions[4] - index*/);

            IndexSchema[] indexes = new IndexSchema[dt.Rows.Count];
            int indexIdx = 0;

            foreach (DataRow dr in dt.Rows)
            {
                //Get the list of columns in this index
                DataTable cols = GetSchemaData(connectionString,
                    IndexColumns,
                    null /*restrictions[0] - catalog*/,
                    null /*restrictions[1] - unused*/,
                    table.Name /*restrictions[2] - table*/,
                    (String)dr[IndexesNameColumn] /*restrictions[3] - index*/,
                    null /*restrictions[4] - column*/);

                string[] columns = new string[cols.Rows.Count];
                int colIdx = 0;
                foreach (DataRow col in cols.Rows)
                {
                    columns[colIdx++] = (String)col[IndexColumnsNameColumn];
                }

                indexes[indexIdx++] =  new IndexSchema(table,
                    (String)dr[IndexesNameColumn],
                    dr.IsNull(IndexesIsPkeyColumn) ? false : (bool)dr[IndexesIsPkeyColumn],
                    dr.IsNull(IndexesIsUniqueColumn) ? false : (bool)dr[IndexesIsUniqueColumn],
                    dr.IsNull(IndexesIsClusteredColumn) ? false : (bool)dr[IndexesIsClusteredColumn],
                    columns);
            }

            return indexes;
        }
        public PrimaryKeySchema GetTablePrimaryKey(string connectionString, TableSchema table)
        {
            DataTable dt = GetSchemaData(connectionString,
                Indexes,
                null /*restrictions[0] - catalog*/,
                null /*restrictions[1] - unused*/,
                table.Name /*restrictions[2] - table*/,
                null /*restrictions[3] - unused*/,
                null /*restrictions[4] - index*/);

            //Find the primary key index
            foreach (DataRow dr in dt.Rows)
            {
                if (!dr.IsNull(IndexesIsPkeyColumn) && (bool)dr[IndexesIsPkeyColumn])
                {
                    //Get the list of columns in this primary key
                    DataTable cols = GetSchemaData(connectionString,
                        IndexColumns,
                        null /*restrictions[0] - catalog*/,
                        null /*restrictions[1] - unused*/,
                        table.Name /*restrictions[2] - table*/,
                        (String)dr[IndexesNameColumn] /*restrictions[3] - index*/,
                        null /*restrictions[4] - column*/);

                    string[] columns = new string[cols.Rows.Count];
                    int colIdx = 0;
                    foreach (DataRow col in cols.Rows)
                    {
                        columns[colIdx++] = (String)col[IndexColumnsNameColumn];
                    }

                    return new PrimaryKeySchema(table,
                        (String)dr[IndexesNameColumn],
                        columns);
                }
            }

            //No pkey
            return null;
        }
        /// <inheritdoc />
        public override PagedAsyncEnumerable <TableDataList, BigQueryRow> ListRowsAsync(TableReference tableReference, TableSchema schema = null, ListRowsOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            // TODO: This is a synchronous call. We can't easily make this part asynchronous - we don't have a cancellation token, and we're returning
            // a non-task value. We could defer until the first MoveNext call, but that's tricky.
            schema = schema ?? GetSchema(tableReference);

            var pageManager = new TableRowPageManager(this, schema);

            return(new RestPagedAsyncEnumerable <TabledataResource.ListRequest, TableDataList, BigQueryRow>(
                       () => CreateListRequest(tableReference, options), pageManager));
        }
Exemplo n.º 52
0
        /// <inheritdoc />
        public override async Task <BigQueryJob> CreateLoadJobAsync(IEnumerable <string> sourceUris, TableReference destination, TableSchema schema, CreateLoadJobOptions options = null, CancellationToken cancellationToken = default)
        {
            var job = await CreateLoadJobRequest(sourceUris, destination, schema, options).ExecuteAsync(cancellationToken).ConfigureAwait(false);

            return(new BigQueryJob(this, job));
        }
Exemplo n.º 53
0
        /// <summary>
        /// Generates SQL for all the columns in table
        /// </summary>
        /// <param name="tableSchema">The table schema.</param>
        /// <returns>
        /// SQL fragment representing the supplied columns.
        /// </returns>
        protected virtual string GenerateColumns(TableSchema.Table tableSchema)
        {
            StringBuilder createSql = new StringBuilder();

            foreach(TableSchema.TableColumn col in tableSchema.Columns)
                createSql.AppendFormat("\r\n  {0}{1},", tableSchema.Provider.FormatIdentifier(col.ColumnName), GenerateColumnAttributes(col));
            string columnSql = createSql.ToString();
            return Strings.Chop(columnSql, ",");
        }
 internal TableRowPageManager(BigQueryClient client, TableSchema schema)
 {
     _client = client;
     _schema = schema;
     _fieldNameToIndexMap = schema.IndexFieldNames();
 }
        public System.Data.DataTable GetTableData(string connectionString, TableSchema table)
        {
            using (SQLiteConnection conn = GetConnection(connectionString))
            {
                using (SQLiteCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.TableDirect;
                    cmd.CommandText = table.Name;

                    SQLiteDataAdapter da = new SQLiteDataAdapter();
                    da.SelectCommand = cmd;

                    DataSet ds = new DataSet();
                    da.Fill(ds);

                    return ds.Tables[0];
                }
            }
        }
 /// <summary>
 /// Creates a field that holds a delegate to a method that filters rows from the client data model.
 /// </summary>
 /// <param name="tableSchema">A description of the table.</param>
 public FilterRowHandlerField(TableSchema tableSchema)
 {
     //            private global::FluidTrade.Core.FilterRowDelegate filterRowHandler;
     this.Type = new CodeTypeReference("FilterRowDelegate");
     this.Name = "filterRowHandler";
 }
        public TableKeySchema[] GetTableKeys(string connectionString, TableSchema table)
        {
            //0, 2, 3; catalog, table, key name
            DataTable dt = GetSchemaData(connectionString,
                ForeignKeys,
                null /*restrictions[0] - catalog*/,
                null /*restrictions[1] - unused*/,
                table.Name /*restrictions[2] - table*/,
                null /*restrictions[3] - key name*/);

            TableKeySchema[] keys = new TableKeySchema[dt.Rows.Count];
            int keyIdx = 0;

            foreach (DataRow dr in dt.Rows)
            {
                TableKeySchema key = new TableKeySchema(table.Database,
                    (String)dr[ForeignKeysNameColumn],
                    new string[] { (String)dr[ForeignKeysFromColColumn] },
                    (String)dr[ForeignKeysFromTableColumn],
                    new string[] { (String)dr[ForeignKeysToColColumn] },
                    (String)dr[ForeignKeysToTableColumn]);

                keys[keyIdx++] = key;
            }

            return keys;
        }
Exemplo n.º 58
0
 public override ColumnSchema[] GetTableColumns(string connectionString, TableSchema table)
 {
     throw new NotImplementedException();
 }
        public TableSchema[] GetTables(string connectionString, DatabaseSchema database)
        {
            //Get only the 'tables' of type 'table'.  The 'Tables' catlog also includes
            //system tables, and the views

            DataTable dt = GetSchemaData(connectionString,
                Tables,
                null /*restrictions[0] - catalog*/,
                null /*restrictions[1] - unused*/,
                null /*restrictions[2] - table*/,
                TableType /*restrictions[3] - type*/);

            TableSchema[] tables = new TableSchema[dt.Rows.Count];
            int tableSchemaIdx = 0;
            foreach (DataRow dr in dt.Rows)
            {
                TableSchema table = new TableSchema(database,
                    (String)dr[TableNameColumn],
                    String.Empty,
                    DateTime.MinValue);
                tables[tableSchemaIdx++] = table;
            }

            return tables;
        }
 /// <summary>
 /// Creates a statement method invocation that adds a record to an ADO transaction.
 /// </summary>
 /// <param name="transactionExpression">The MiddleTierContext used for the transaction.</param>
 /// <param name="columnSchema">The record that is held for the duration of the transaction.</param>
 public CodeAcquireRecordWriterLockExpression(CodeVariableReferenceExpression transactionExpression, CodeVariableReferenceExpression rowExpression, TableSchema tableSchema)
 {
     //			configurationRow.AcquireWriterLock(middleTierTransaction.AdoResourceManager.Guid, FluidTrade.UnitTest.Server.DataModel.lockTimeout);
     this.Method = new CodeMethodReferenceExpression(rowExpression, "AcquireWriterLock");
     this.Parameters.Add(new CodePropertyReferenceExpression(transactionExpression, "TransactionId"));
     this.Parameters.Add(new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(tableSchema.DataModel.Name), "lockTimeout"));
 }