本文整理汇总了C#中System.Data.UniqueConstraint类的典型用法代码示例。如果您正苦于以下问题:C# UniqueConstraint类的具体用法?C# UniqueConstraint怎么用?C# UniqueConstraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UniqueConstraint类属于System.Data命名空间,在下文中一共展示了UniqueConstraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildTable
public void BuildTable()
{
DataTable table = new DataTable(_table);
DataColumnCollection cols = table.Columns;
cols.Add(_Id, typeof(int));
cols.Add(_UserName, typeof(string));
cols.Add(_Password, typeof(string));
cols.Add(_ContactName, typeof(string));
cols.Add(_Company, typeof(string));
cols.Add(_JobTitle, typeof(string));
cols.Add(_BillingAddress, typeof(string));
cols.Add(_BillingCity, typeof(string));
cols.Add(_BillingZipCode, typeof(string));
cols.Add(_BillingCountry, typeof(string));
cols.Add(_ShippingCity, typeof(string));
cols.Add(_ShippingZipCode, typeof(string));
cols.Add(_ShippingCountry, typeof(string));
cols.Add(_MobilePhone, typeof(string));
cols.Add(_OfficePhone, typeof(string));
cols.Add(_HomePhone, typeof(string));
cols.Add(_FaxNumber, typeof(string));
cols.Add(_TaxCode, typeof(string));
cols.Add(_Email1, typeof(string));
cols.Add(_Email2, typeof(string));
cols.Add(_Website, typeof(string));
UniqueConstraint uc = new UniqueConstraint(cols[_Id], true);
table.Constraints.Add(uc);
this.Tables.Add(table);
}
示例2: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint(dtParent.Columns[0]);
try
{
BeginCase("default ");
Compare(uc.ConstraintName ,string.Empty );
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
uc.ConstraintName = "myConstraint";
try
{
BeginCase("set/get ");
Compare(uc.ConstraintName ,"myConstraint" );
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例3: BuildTable
public void BuildTable()
{
DataTable table = new DataTable(_table);
DataColumnCollection cols = table.Columns;
cols.Add(_id, typeof(int));
cols.Add(_OrderNumber, typeof(string));
cols.Add(_ParentId, typeof(int));
cols.Add(_OrderDate, typeof(DateTime));
cols.Add(_EmployeeId, typeof(int));
cols.Add(_CustomerId, typeof(int));
cols.Add(_POSId, typeof(int));
cols.Add(_OrderStateId, typeof(int));
cols.Add(_OrderTypeId, typeof(int));
cols.Add(_ShipDate, typeof(DateTime));
cols.Add(_ShipperId, typeof(int));
cols.Add(_ShipperName, typeof(string));
cols.Add(_ShippingFee, typeof(float));
cols.Add(_CurrencyId, typeof(int));
cols.Add(_CurrencyRate, typeof(int));
cols.Add(_ShippingName, typeof(string));
cols.Add(_ShippingAddress, typeof(string));
cols.Add(_ShippingCity, typeof(string));
cols.Add(_ShippingZipCode, typeof(string));
cols.Add(_ShippingCounttry, typeof(string));
cols.Add(_Phone, typeof(string));
cols.Add(_email, typeof(string));
UniqueConstraint uc = new UniqueConstraint(cols[_id], true);
table.Constraints.Add(uc);
this.Tables.Add(table);
}
示例4: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataSet ds = new DataSet();
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
ds.Tables.Add(dtParent);
UniqueConstraint uc1,uc2;
uc1 = new UniqueConstraint(dtParent.Columns[0]);
uc2 = new UniqueConstraint(dtParent.Columns[1]);
try
{
BeginCase("different columnn");
Compare(uc1.Equals(uc2),false);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
//Two System.Data.ForeignKeyConstraint are equal if they constrain the same columns.
try
{
BeginCase("same column");
uc2 = new UniqueConstraint(dtParent.Columns[0]);
Compare(uc1.Equals(uc2),true);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例5: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint(dtParent.Columns[0],false);
dtParent.Constraints.Add(uc);
try
{
BeginCase("primary key 1");
Compare(uc.IsPrimaryKey , false);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
dtParent.Constraints.Remove(uc);
uc = new UniqueConstraint(dtParent.Columns[0],true);
dtParent.Constraints.Add(uc);
try
{
BeginCase("primary key 2");
Compare(uc.IsPrimaryKey , true);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例6: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint(dtParent.Columns[0]);
try
{
BeginCase("Columns 1");
Compare(uc.Columns.Length ,1);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
BeginCase("Columns 2");
Compare(uc.Columns[0],dtParent.Columns[0]);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例7: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint("myConstraint",new DataColumn[] {dtParent.Columns[0],dtParent.Columns[1]});
try
{
BeginCase("Ctor");
Compare(uc == null ,false );
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
BeginCase("Ctor name");
Compare(uc.ConstraintName ,"myConstraint");
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例8: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint(dtParent.Columns[0],false);
try
{
BeginCase("ToString - default");
Compare(uc.ToString(), string.Empty );
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
uc = new UniqueConstraint("myConstraint",dtParent.Columns[0],false);
try
{
BeginCase("Tostring - Constraint name");
Compare(uc.ToString(), "myConstraint");
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例9: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint(dtParent.Columns[0]);
PropertyCollection pc = uc.ExtendedProperties ;
try
{
base.BeginCase("Checking ExtendedProperties default ");
base.Compare(pc != null,true);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
base.BeginCase("Checking ExtendedProperties count ");
base.Compare(pc.Count ,0);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例10: SqlCommandUniqueValidator
public SqlCommandUniqueValidator(
ITablePopulator table,
UniqueConstraint unique,
string connectionString
)
: base(table,unique,new SqlFactory(),connectionString)
{
}
示例11: UniqueValidatorBase
public UniqueValidatorBase(ITablePopulator table, UniqueConstraint unique)
{
if(table==null)
throw new ArgumentNullException("table");
if(unique==null)
throw new ArgumentNullException("unique");
this.table=new WeakReference(table);
this.unique=unique;
}
示例12: run
//Activate This Construntor to log All To Standard output
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
public void run()
{
Exception exp = null;
DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
UniqueConstraint uc = null;
uc = new UniqueConstraint("myConstraint",dtParent.Columns[0],false);
dtParent.Constraints.Add(uc);
try
{
BeginCase("Ctor");
Compare(uc == null ,false );
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
BeginCase("primary key 1");
Compare(dtParent.PrimaryKey.Length ,0);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
BeginCase("Ctor name 1");
Compare(uc.ConstraintName ,"myConstraint");
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
dtParent.Constraints.Remove(uc);
uc = new UniqueConstraint("myConstraint",dtParent.Columns[0],true);
dtParent.Constraints.Add(uc);
try
{
BeginCase("primary key 2");
Compare(dtParent.PrimaryKey.Length ,1);
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
try
{
BeginCase("Ctor name 2");
Compare(uc.ConstraintName ,"myConstraint");
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
示例13: Add
public Constraint Add(string name, DataColumn[] columns, bool primaryKey)
{
UniqueConstraint constraint = new UniqueConstraint(name, columns);
this.Add(constraint);
if (primaryKey)
{
this.Table.PrimaryKey = columns;
}
return constraint;
}
示例14: ArticulosItems
public static DataTable ArticulosItems()
{
DataTable tblArticulosItems = datos.Tables[1];
tblArticulosItems.TableName = "ArticulosItems";
if (!tblArticulosItems.Constraints.Contains("descripcionConstraint"))
{
UniqueConstraint uniqueConstraint = new UniqueConstraint("descripcionConstraint", tblArticulosItems.Columns["DescripcionITE"]);
tblArticulosItems.Constraints.Add(uniqueConstraint);
}
return tblArticulosItems;
}
示例15: Clientes
public static DataTable Clientes()
{
DataTable tblClientes = datos.Tables[2];
tblClientes.TableName = "Clientes";
if (!tblClientes.Constraints.Contains("idConstraint"))
{
UniqueConstraint uniqueConstraint = new UniqueConstraint("idConstraint", tblClientes.Columns["CorreoCLI"]);
tblClientes.Constraints.Add(uniqueConstraint);
}
return tblClientes;
}