本文整理汇总了C#中EntityProperties.Add方法的典型用法代码示例。如果您正苦于以下问题:C# EntityProperties.Add方法的具体用法?C# EntityProperties.Add怎么用?C# EntityProperties.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityProperties
的用法示例。
在下文中一共展示了EntityProperties.Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPrimaryKeyProperties
private EntityProperties GetPrimaryKeyProperties(DataEntity dataEntity, OleDbMetadataAccess metadataAccess)
{
var primaryKeyProperties = new EntityProperties();
//Use the data entity name to retrieve a list of indexes
var indexColumns = metadataAccess.GetTableIndexInformation(dataEntity.ObjectDefinitionFullName);
//Add each of the Primary Keys and their values found in the data entity.
foreach (DataRow row in indexColumns.Rows)
{
if (!Convert.ToBoolean(row["PRIMARY_KEY"]))
{
continue;
}
var columnName = row["COLUMN_NAME"].ToString();
// Check if the priamry key column is included in the data entity.
if (dataEntity.Properties.ContainsKey(columnName))
{
// Add the key and its value to the primary key list.
primaryKeyProperties.Add(columnName, dataEntity.Properties[columnName]);
}
else
{
// If the key has not been added set it to null.
primaryKeyProperties.Add(columnName, null);
}
}
return primaryKeyProperties;
}
示例2: UpdateInvalidIntTest
public void UpdateInvalidIntTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = false };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.Equal,
new ComparisonValue(ComparisonValueType.Property, "Region"),
new ComparisonValue(ComparisonValueType.Constant, "North"),
null)
};
//add the columns to change
table.ObjectDefinitionFullName = "Customers";
columnData.Add("CreditOnHold", "5328475903427853943453245324532453425345324523453453453425345324523452342345");
columnData.Add("ModifiedOn", DateTime.Now);
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
var operationResult = _sysConnector.ExecuteOperation(operationInput);
//validate that the result of the operation was not a success
Assert.IsFalse(operationResult.Success[0]);
//validate that no objects have been affected
Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
}
示例3: UpdateMultipleRowsValidTest
public void UpdateMultipleRowsValidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = true };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(
ComparisonOperator.IsNull,new ComparisonValue(ComparisonValueType.Property, "TaxSchedule"), null, null)
};
//add the columns to change
table.ObjectDefinitionFullName = "Addresses";
columnData.Add("TaxSchedule", "ST-PA");
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the selected operaiton
var operationResult = _sysConnector.ExecuteOperation(operationInput);
//validate that the operation was success
Assert.IsTrue(operationResult.Success[0]);
//validate that multiple rows have been updated
Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
}
示例4: UpdateBooleanValidTest
public void UpdateBooleanValidTest()
{
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
var operationInput = new OperationInput();
operationInput.Name = "update";
operationInput.AllowMultipleObject = false;
//create a new comparison expression that will only attempt to update one row of data
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.Equal,
new ComparisonValue(ComparisonValueType.Property, "ProductNumber"),
new ComparisonValue(ComparisonValueType.Constant,"ME256"),
null)
};
table.ObjectDefinitionFullName = "Products";
//This will only accept a value that has a value of 1, or 0 for TRUE or FALSE
columnData.Add("Discontinued", 1);
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
var operationResult = _sysConnector.ExecuteOperation(operationInput);
//validate the the result was a success
Assert.IsTrue(operationResult.Success[0]);
//validate that only one row of data was affected
Assert.AreEqual(1, operationResult.ObjectsAffected[0]);
}
示例5: UpdateInvalidDateTest
public void UpdateInvalidDateTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = false };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.Equal,
new ComparisonValue(ComparisonValueType.Property, "Type"),
new ComparisonValue(ComparisonValueType.Constant, "Order"),
null)
};
//add the columns to change
table.ObjectDefinitionFullName = "SalesOrders";
columnData.Add("OrderDate", InvalidPropertyValue);
columnData.Add("ModifiedOn", DateTime.Now);
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
var operationResult = _sysConnector.ExecuteOperation(operationInput);
Assert.IsFalse(operationResult.Success[0]);
Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
}
示例6: InsertRowValidTest
public void InsertRowValidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "create" };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create a DataEntity for the row
table.ObjectDefinitionFullName = "Products";
columnData.Add("RecordId", Guid.NewGuid().ToString());
columnData.Add("ProductNumber", DateTime.Now.GetHashCode());
columnData.Add("ProductName", "Screwdriver");
columnData.Add("Type", "FinishGood");
columnData.Add("UoMSchedule", null);
columnData.Add("ListPrice", "65");
columnData.Add("Cost", "65");
columnData.Add("StandardCost", "65");
columnData.Add("QuantityInStock", "65");
columnData.Add("QuantityOnOrder", "65");
columnData.Add("Discontinued", "0");
//add the row data to the input
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the selected operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//verify the result is a success
Assert.IsTrue(operationResult.Success[0]);
//verify that a row was added
Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
}
示例7: InsertUnknownTableInValidTest
public void InsertUnknownTableInValidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "create" };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create a DataEntity for the row
table.ObjectDefinitionFullName = InvalidPropertyValue;
columnData.Add("RecordId", Guid.NewGuid().ToString());
columnData.Add("ProductNumber", "134234g");
columnData.Add("ProductName", "Screwdriver");
columnData.Add("Type", "FinishGood");
columnData.Add("UoMSchedule", "65");
columnData.Add("ListPrice", "65");
columnData.Add("Cost", "65");
columnData.Add("StandardCost", "65");
columnData.Add("QuantityInStock", "65");
columnData.Add("QuantityOnOrder", "65");
columnData.Add("Discontinued", "0");
columnData.Add("CreatedOn", DateTime.Now);
columnData.Add("ModifiedOn", DateTime.Now);
//add the row data to the input
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the selected operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//verify the result is not a success
Assert.IsFalse(operationResult.Success[0]);
Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
}
示例8: UpsertingExistingRowInvalidTest
public void UpsertingExistingRowInvalidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "upsert" };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create a DataEntity for the row
table.ObjectDefinitionFullName = "Customers";
columnData.Add("CustomerNumber", "ABERDEEN0001");
columnData.Add("CompanyName", "Aberdeen Inc.");
columnData.Add("Active", "1");
columnData.Add("Email", "[email protected]");
//add the row data to the input
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the selected operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//verify the result is a success
Assert.IsTrue(operationResult.Success[0]);
//verify that a row was added
Assert.AreEqual(1, operationResult.ObjectsAffected[0]);
}
示例9: InsertExistingRowInvalidTest
public void InsertExistingRowInvalidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "create" };
var input = new List<DataEntity>();
var table = new DataEntity("Customers");
var columnData = new EntityProperties();
//create a DataEntity for the row
table.ObjectDefinitionFullName = "Customers";
columnData.Add("CustomerNumber", "ABERDEEN0001");
columnData.Add("CompanyName", "Aberdeen Inc.");
columnData.Add("Active", "1");
//add the row data to the input
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the selected operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//verify the result is not a success
Assert.IsFalse(operationResult.Success[0]);
//verify that a row was added
Assert.AreEqual(ErrorNumber.DuplicateUniqueKey, operationResult.ErrorInfo[0].Number);
}
示例10: UpdateValidTest
public void UpdateValidTest()
{
OperationInput operationInput = new OperationInput();
List<DataEntity> input = new List<DataEntity>();
DataEntity table = new DataEntity();
EntityProperties columnData = new EntityProperties();
operationInput.Name = "update";
operationInput.AllowMultipleObject = false;
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.Equal,
new ComparisonValue(ComparisonValueType.Property, "Addresses.CustomerNumber"),
new ComparisonValue(ComparisonValueType.Constant, "LITWAREI0001"),
null)
};
//add the columns to change
table.ObjectDefinitionFullName = "Addresses";
columnData.Add("Fax", "NA");
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//validate that the operation was successfull
Assert.IsTrue(operationResult.Success[0]);
//validate that only one records has been updated
Assert.AreEqual(1, operationResult.ObjectsAffected[0]);
}
示例11: UpdateTooManyRowsInvalidTest
public void UpdateTooManyRowsInvalidTest()
{
OperationInput operationInput = new OperationInput();
List<DataEntity> input = new List<DataEntity>();
DataEntity table = new DataEntity();
EntityProperties columnData = new EntityProperties();
operationInput.Name = "update";
//note: altering of multiple rows is not allowed
operationInput.AllowMultipleObject = false;
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.IsNull,
new ComparisonValue(ComparisonValueType.Constant, "Description"),
null,
null)
};
//add the columns to change
table.ObjectDefinitionFullName = "PickLists";
columnData.Add("Description", "");
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the operation
OperationResult operationResult = _sysConnector.ExecuteOperation(operationInput);
//validate that the update was a success
Assert.IsTrue(operationResult.Success[0]);
Assert.AreEqual(0, operationResult.ObjectsAffected[0]);
}
示例12: UpdateReplicationTest
public void UpdateReplicationTest()
{
OperationInput operationInput = new OperationInput();
List<DataEntity> input = new List<DataEntity>();
DataEntity table = new DataEntity();
EntityProperties columnData = new EntityProperties();
operationInput.Name = "update";
operationInput.AllowMultipleObject = false;
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(ComparisonOperator.Equal,
new ComparisonValue(ComparisonValueType.Constant, "State"),
new ComparisonValue(ComparisonValueType.Constant, "MA"),
null)
};
//add the columns to change
table.ObjectDefinitionFullName = "Addresses";
columnData.Add("Fax", "NA");
columnData.Add("ModifiedOn", DateTime.Now);
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
//execute the operation
OperationResult operationResult = _rsTargetConnector.ExecuteOperation(operationInput);
Assert.IsTrue(operationResult.Success[0]);
Assert.IsTrue(operationResult.ObjectsAffected[0] >=1);
}
示例13: UpdateReplicationNullValueValidTest
public void UpdateReplicationNullValueValidTest()
{
//create a new method input and use the appropriate operation name
OperationInput operationInput = new OperationInput { Name = "update", AllowMultipleObject = false };
var input = new List<DataEntity>();
var table = new DataEntity();
var columnData = new EntityProperties();
//create the comparison experssion for selecting the records to update
operationInput.LookupCondition = new Expression[]
{
new ComparisonExpression(
ComparisonOperator.IsNull,new ComparisonValue(ComparisonValueType.Constant, "Country"), null, null)
};
//add the columns to change
table.ObjectDefinitionFullName = "Addresses";
columnData.Add("Country", "USA");
columnData.Add("ModifiedOn", DateTime.Now);
table.Properties = columnData;
input.Add(table);
operationInput.Input = input.ToArray();
var operationResult = _rsTargetConnector.ExecuteOperation(operationInput);
Assert.IsTrue(operationResult.Success[0]);
Assert.IsTrue(operationResult.ObjectsAffected[0] >= 1);
}