You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.9 KiB
54 lines
1.9 KiB
using System.Data.SqlClient;
|
|
using OpenDBDiff.SqlServer.Schema.Model;
|
|
|
|
namespace OpenDBDiff.SqlServer.Schema.Generates
|
|
{
|
|
public class GeneratePartitionScheme
|
|
{
|
|
private Generate root;
|
|
|
|
public GeneratePartitionScheme(Generate root)
|
|
{
|
|
this.root = root;
|
|
}
|
|
|
|
private static string GetSQL()
|
|
{
|
|
return SQLQueries.SQLQueryFactory.Get("GetPartitionSchemes");
|
|
}
|
|
|
|
public void Fill(Database database, string connectioString)
|
|
{
|
|
int lastObjectId = 0;
|
|
PartitionScheme item = null;
|
|
if (database.Options.Ignore.FilterPartitionScheme)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(connectioString))
|
|
{
|
|
using (SqlCommand command = new SqlCommand(GetSQL(), conn))
|
|
{
|
|
conn.Open();
|
|
command.CommandTimeout = 0;
|
|
using (SqlDataReader reader = command.ExecuteReader())
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
if (lastObjectId != (int)reader["ID"])
|
|
{
|
|
lastObjectId = (int)reader["ID"];
|
|
item = new PartitionScheme(database);
|
|
item.Id = (int)reader["ID"];
|
|
item.Name = reader["name"].ToString();
|
|
item.PartitionFunction = reader["FunctionName"].ToString();
|
|
database.PartitionSchemes.Add(item);
|
|
}
|
|
item.FileGroups.Add(reader["FileGroupName"].ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|