本文整理汇总了C#中System.Data.DataRowCollection.Find方法的典型用法代码示例。如果您正苦于以下问题:C# DataRowCollection.Find方法的具体用法?C# DataRowCollection.Find怎么用?C# DataRowCollection.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRowCollection
的用法示例。
在下文中一共展示了DataRowCollection.Find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: findRow
private DataRow findRow(DataRowCollection rows, Type type, string keyvalue)
{
DataRow row = null;
if (type != typeof(Guid))
{
row = rows.Find(Convert.ChangeType(keyvalue, type));
}
else
{
row = rows.Find(new Guid(keyvalue));
}
return row;
}
示例2: GetPropertiesFromDataRows
private IPropertyCollection GetPropertiesFromDataRows(DataRowCollection rows,
IContext context,
ITransaction transaction) {
var schema = (context == null || string.IsNullOrEmpty(context.Name)
? GetDefaultContextSchema()
: GetContextSchema(context.Name, transaction));
var propertyList = new List<IProperty>();
foreach(var pd in schema) {
string propertyValue = null;
var propertyName = pd.PropertyName;
var propertyType = pd.PropertyType;
var currentField = (rows != null ? rows.Find(pd.PropertyName) : null);
if(currentField != null) {
if(!currentField.IsNull("PropertyValue")) {
propertyValue = (string)currentField["PropertyValue"];
} else {
propertyValue = (string)currentField["ExtendedPropertyValue"];
}
}
var property = PropertyFactory.Create(propertyName, propertyValue, propertyType, context);
if(property != null) {
propertyList.Add(property);
}
}
return new PropertyCollection(propertyList, schema);
}
示例3: ParseAccountData
private void ParseAccountData(XmlNode accountsData, DataRowCollection orders, Dictionary<Guid, Transaction> exectuedTransactions,
out AccountBalance[] accountBalances, out AccountCurrency[] accountCurrencies, out Contract[] contracts)
{
accountBalances = null;
accountCurrencies = null;
contracts = null;
if (accountsData != null)
{
accountBalances = new AccountBalance[accountsData.ChildNodes.Count];
List<AccountCurrency> accountCurrencyList = new List<AccountCurrency>();
List<Contract> contractList = new List<Contract>();
int index = 0;
foreach (XmlElement account in accountsData.ChildNodes)
{
AccountBalance accountBalance = new AccountBalance();
accountBalance.Initialize(account);
accountBalances[index++] = accountBalance;
foreach (XmlElement xmlChild in account.ChildNodes)
{
if (xmlChild.Name == "Currency")
{
AccountCurrency accountCurrency = new AccountCurrency();
accountCurrency.AccountId = accountBalance.AccountId;
accountCurrency.Initialize(xmlChild);
accountCurrencyList.Add(accountCurrency);
}
else if (xmlChild.Name == "Orders")
{
foreach (XmlElement orderNode in xmlChild.ChildNodes)
{
Guid orderId = XmlConvert.ToGuid(orderNode.Attributes["ID"].Value);
DataRow orderRow = orders.Find(new object[] { orderId });
if (orderRow != null)
{
Guid transactionId = (Guid)(orderRow["TransactionID"]);
if (exectuedTransactions.ContainsKey(transactionId))
{
Contract contract = new Contract();
contract.Initialize(orderRow);
contract.Initialize(orderNode);
contractList.Add(contract);
}
}
}
}
}
}
contracts = contractList.ToArray();
accountCurrencies = accountCurrencyList.ToArray();
}
}
示例4: FindRow
public static DataRow FindRow(DataRowCollection rows, string type, string keyvalue)
{
DataRow row = null;
if (type == "system.uint" || type == "system.uint32")
{
row = rows.Find(Convert.ToUInt32(keyvalue));
}
else if (type == "system.uint16")
{
row = rows.Find(Convert.ToUInt16(keyvalue));
}
else if (type == "system.uint64")
{
row = rows.Find(Convert.ToUInt64(keyvalue));
}
else if (type == "system.int" || type == "system.int32")
{
row = rows.Find(Convert.ToInt32(keyvalue));
}
else if (type == "system.int16")
{
row = rows.Find(Convert.ToInt16(keyvalue));
}
else if (type == "system.int64")
{
row = rows.Find(Convert.ToInt64(keyvalue));
}
else if (type == "system.single")
{
row = rows.Find(Convert.ToSingle(keyvalue));
}
else if (type == "system.double")
{
row = rows.Find(Convert.ToDouble(keyvalue));
}
else if (type == "system.decimal")
{
row = rows.Find(Convert.ToDecimal(keyvalue));
}
else if (type == "system.datetime")
{
row = rows.Find(Convert.ToDateTime(keyvalue));
}
else
{
row = rows.Find(keyvalue);
}
return row;
}