Ejemplo n.º 1
0
		public static void Callup(IQueryBuilder<IRootQuery> builder, string tableName, string database)
		{
			builder.QueryText("SELECT ccu.column_name AS SourceColumn ,kcu.table_name AS TargetTable ,kcu.column_name AS TargetColumn")
				.QueryText("FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu")
				.QueryText("INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc")
				.QueryText("ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME")
				.QueryText("INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu")
				.QueryText("ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME")
				.QueryD("WHERE ccu.TABLE_NAME = @tableName AND ccu.TABLE_CATALOG = @database", new
				{
					database = database,
					tableName = tableName
				})
				.QueryText("ORDER BY ccu.table_name");
		}