本文整理汇总了C#中Model.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlistVisitingLogTrs
public List<DicReader> GetPlistVisitingLogTrs(string key, DateTime? leftVisitOn, DateTime? rightVisitOn, PagingInput paging)
{
paging.Valid();
if (key != null)
{
key = key.Trim();
}
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
var filterString = @" where a.LoginName like @key ";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
if (leftVisitOn.HasValue)
{
parameters.Add(CreateParameter("leftVisitOn", leftVisitOn.Value, DbType.DateTime));
filterString += " and a.VisitOn>[email protected]";
}
if (rightVisitOn.HasValue)
{
parameters.Add(CreateParameter("rightVisitOn", rightVisitOn.Value, DbType.DateTime));
filterString += " and a.VisitOn<@rightVisitOn";
}
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("VisitingLog", filter, paging);
}
示例2: GetAllCategories
public Category[] GetAllCategories()
{
List<Category> myCategories = new List<Category>();
SqlConnection myConn = new SqlConnection(connstring);
myConn.Open();
SqlCommand mySqlCommand = new SqlCommand("select * from Category", myConn);
SqlDataReader reader = mySqlCommand.ExecuteReader();
while (reader.Read())
{
Category myCategory = new Category();
object id = reader["Id"];
if (id != null)
{
int categoryId = -1;
if (!int.TryParse(id.ToString(), out categoryId))
{
throw new Exception("Failed to parse Id of video.");
}
myCategory.Id = categoryId;
}
myCategory.Name = reader["Name"].ToString();
myCategories.Add(myCategory);
}
myConn.Close();
return myCategories.ToArray();
}
示例3: InsertBatch
static void InsertBatch()
{
Console.WriteLine("Inserting a bunch of trial data objects...");
var trialBatch = new List<Model.TrialData>();
var random = new Random();
var watch = new Stopwatch();
watch.Start();
for(int i=1; i<=50000; i++)
{
var parameters = new List<Parameter> {new Parameter { Name = "GBP.TotalReturnIndex", TrialNumber = 1, Value = random.NextDouble() },
new Parameter { Name = "USD.TotalReturnIndex", TrialNumber = 2, Value = random.NextDouble() },
new Parameter { Name = "EUR.TotalReturnIndex", TrialNumber = 3, Value = random.NextDouble() }};
var trialData = new TrialData { StressNumber = i, Parameters = parameters.ToArray() };
//var ravenConnection = new RavenConnection { ServerUrl = "http://localhost:8081/", DatabaseName = "TrialData" };
//Console.WriteLine("Inserting Stress {0}", i);
//var ravenDB = new RavenDB();
//var elapsed = ravenDB.PostTrialData(ravenConnection, trialData);
//Console.WriteLine("insert complete in {0}ms", elapsed);
trialBatch.Add(trialData);
}
var ravenConnection = new Model.RavenConnection { ServerUrl = "http://localhost:8081/", DatabaseName = "TrialData" };
var ravenDB = new RavenDB();
var elapsed = ravenDB.BulkInsertTrialData(ravenConnection, trialBatch);
watch.Stop();
//var elapsed = ravenDB.BulkInsertTrialDataEmbedded(ravenConnection, trialBatch);
Console.WriteLine();
Console.WriteLine("Operation complete in {0} minutes, {1} seconds and {2} milliseconds", watch.Elapsed.Minutes, watch.Elapsed.Seconds, watch.Elapsed.Milliseconds);
}
示例4: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ScrollViewer.SetVerticalScrollMode(CategoryPageGridView, ScrollMode.Disabled);
CategoryPageViewModel categoryPageViewModel =
(CategoryPageViewModel)Resources["CategoryPageViewModel"];
NavigationItem navigationItem = e.Parameter as NavigationItem;
var task = Task.Factory.StartNew(async () =>
{
var bundle = await DownloadNavigationItem(navigationItem.ReferralId);
var navigationItems = await DownloadNavigationItemsAsync();
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High,
() =>
{
categoryPageViewModel.Content = bundle.Content[0];
var items = new List<Content>(bundle.Content);
items.RemoveAt(0);
bundle.Content = items.ToArray();
categoryPageViewModel.Bundle = bundle;
categoryPageViewModel.NavigationItems = navigationItems;
LoadingGrid.Visibility = Visibility.Collapsed;
MySplitView.Visibility = Visibility.Visible;
}
);
});
base.OnNavigatedTo(e);
}
示例5: ReadJson
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
HaParams returnValue = null;
var deserializationErrorMessage = "Could not read ha-params value";
if (reader.TokenType == JsonToken.Integer)
{
returnValue = new HaParams {AssociatedHaMode = HaMode.Exactly, ExactlyCount = (long)reader.Value};
}else if (reader.TokenType == JsonToken.StartArray)
{
var potentialReturnValue = new HaParams {AssociatedHaMode = HaMode.Nodes};
var nodesList = new List<string>();
do
{
reader.Read();
if (!new[] {JsonToken.EndArray, JsonToken.String}.Contains(reader.TokenType))
{
deserializationErrorMessage = "Could not read ha-params array value";
}
else if(reader.TokenType == JsonToken.String)
{
nodesList.Add(reader.Value as string);
}
} while (reader.TokenType == JsonToken.String);
potentialReturnValue.Nodes = nodesList.ToArray();
returnValue = potentialReturnValue;
}
if (returnValue != null)
{
return returnValue;
}
throw new JsonSerializationException(deserializationErrorMessage);
}
示例6: GetPlistCatalogAccountTrs
public List<DicReader> GetPlistCatalogAccountTrs(string key, string catalogCode
, bool includeDescendants, PagingInput paging)
{
paging.Valid();
if (string.IsNullOrEmpty(catalogCode))
{
throw new ArgumentNullException("catalogCode");
}
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
var filterString = " where (a.Name like @key or a.Code like @key or a.LoginName like @key)";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
if (!includeDescendants)
{
parameters.Add(CreateParameter("CatalogCode", catalogCode, DbType.String));
filterString += " and [email protected]";
}
else
{
parameters.Add(CreateParameter("CatalogCode", catalogCode + "%", DbType.String));
filterString += " and a.CatalogCode like @CatalogCode";
}
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("CatalogAccountTr", filter, paging);
}
示例7: GetPlistGroupAccountTrs
public List<DicReader> GetPlistGroupAccountTrs(string key, Guid groupId, PagingInput paging)
{
paging.Valid();
Func<SqlFilter> filter = () =>
{
var parameters = new List<DbParameter>();
const string filterString = @" where (a.Name like @key
or a.Code like @key
or a.LoginName like @key) and [email protected]";
parameters.Add(CreateParameter("key", "%" + key + "%", DbType.String));
parameters.Add(CreateParameter("GroupId", groupId, DbType.Guid));
return new SqlFilter(filterString, parameters.ToArray());
};
return base.GetPlist("GroupAccountTr", filter, paging);
}
示例8: UCOldPartsPalautusManager_DeleteEvent
void UCOldPartsPalautusManager_DeleteEvent(object sender, EventArgs e)
{
try
{
List<string> listField = new List<string>();
foreach (DataGridViewRow dr in dgvRData.Rows)
{
object isCheck = dr.Cells["colCheck"].EditedFormattedValue;
if (isCheck != null && (bool)isCheck)
{
listField.Add(dr.Cells["return_id"].Value.ToString());
}
}
if (listField.Count == 0)
{
MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (MessageBoxEx.Show("确认要删除吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
{
return;
}
Dictionary<string, string> comField = new Dictionary<string, string>();
comField.Add("enable_flag", Convert.ToInt32(DataSources.EnumEnableFlag.DELETED).ToString());
comField.Add("update_by", HXCPcClient.GlobalStaticObj.UserID);//修改人Id
comField.Add("update_name", HXCPcClient.GlobalStaticObj.UserName);//修改人姓名
comField.Add("update_time", Common.LocalDateTimeToUtcLong(HXCPcClient.GlobalStaticObj.CurrentDateTime).ToString());//修改时间
bool flag = DBHelper.BatchUpdateDataByIn("批量删除宇通旧件返厂单", "tb_maintain_oldpart_recycle", comField, "return_id", listField.ToArray());
if (flag)
{
BindPageData();
if (dgvRData.Rows.Count > 0)
{
dgvRData.CurrentCell = dgvRData.Rows[0].Cells[0];
}
MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
MessageBoxEx.Show("删除失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
示例9: SearchPreVisitList
//.........这里部分代码省略.........
conditionSb.Append(" AND dr_visit.drid = @drid ");
paraList.Add(new MySqlParameter("drid", drid));
}
if (visit_id > 0)
{
conditionSb.Append(" AND pre.visit_id = @visit_id ");
paraList.Add(new MySqlParameter("visit_id", visit_id));
}
if (patient_id > 0)
{
conditionSb.Append(" AND pre.patient_id = @patient_id ");
paraList.Add(new MySqlParameter("patient_id", patient_id));
}
if (pre_date1.HasValue)
{
conditionSb.Append(" AND DATEDIFF(pre.pre_date,@pre_date1) >= 0 ");
paraList.Add(new MySqlParameter("pre_date1", pre_date1.Value));
}
if (pre_date2.HasValue)
{
conditionSb.Append(" AND DATEDIFF(pre.pre_date,@pre_date2) <= 0 ");
paraList.Add(new MySqlParameter("pre_date2", pre_date2.Value));
}
if (!string.IsNullOrEmpty(pre_time))
{
conditionSb.Append(" AND pre.pre_time = @pre_time ");
paraList.Add(new MySqlParameter("pre_time", pre_time));
}
if (pre_type > 0)
{
conditionSb.Append(" AND pre.pre_type = @pre_type ");
paraList.Add(new MySqlParameter("pre_type", pre_type));
}
if (visit_date1.HasValue)
{
conditionSb.Append(" AND DATEDIFF(pre.createtime,@createtime1) >= 0 ");
paraList.Add(new MySqlParameter("createtime1", createtime1.Value));
}
if (createtime2.HasValue)
{
conditionSb.Append(" AND DATEDIFF(pre.createtime,@createtime2) <= 0 ");
paraList.Add(new MySqlParameter("createtime2", createtime2.Value));
}
if (status > 0)
{
conditionSb.Append(" AND dr_visit.status = @status ");
paraList.Add(new MySqlParameter("status", status));
}
if (visit_date1.HasValue)
{
conditionSb.Append(" AND DATEDIFF(dr_visit.visit_date,@visit_date1) >= 0 ");
paraList.Add(new MySqlParameter("visit_date1", visit_date1.Value));
}
if (visit_date2.HasValue)
{
conditionSb.Append(" AND DATEDIFF(dr_visit.visit_date,@visit_date2) <= 0 ");
paraList.Add(new MySqlParameter("visit_date2", visit_date2.Value));
}
#endregion
#region 排序 分页
string orderbyStr = string.Empty;
if (!string.IsNullOrEmpty(orderbyCol) && orderby.HasValue)
orderbyStr = orderbyFormat.getSortStr(orderby.Value, orderbyCol);
else
orderbyStr = " order by pre.pkid ";
selectSql += conditionSb.ToString() + orderbyStr;
if (pageIndex > 0)
{
selectSql += " LIMIT @pageIndex , @pageSize ";
paraList.Add(new MySqlParameter("pageIndex", (pageIndex - 1) * pageSize));
paraList.Add(new MySqlParameter("pageSize", pageSize));
}
#endregion
#region 执行
var resultList = db.Database.SqlQuery<dr_pre_visit>(selectSql, paraList.ToArray()).ToList();
return resultList;
#endregion
}
catch (Exception ex)
{
error += BaseTool.FormatExceptionMessage(ex);
return null;
}
}
示例10: UCPersonnelManager_DeleteEvent
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void UCPersonnelManager_DeleteEvent(object sender, EventArgs e)
{
List<string> listField = new List<string>();
List<DataGridViewRow> deleteUser = new List<DataGridViewRow>();
foreach (DataGridViewRow dr in dgvUser.Rows)
{
object isCheck = dr.Cells["colCheck"].EditedFormattedValue;
if (isCheck != null && (bool)isCheck)
{
listField.Add(dr.Cells["user_id"].Value.ToString());
deleteUser.Add(dr);
}
}
if (listField.Count == 0)
{
MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (MessageBoxEx.ShowQuestion("是否确认删除?"))
{
Dictionary<string, string> comField = new Dictionary<string, string>();
comField.Add("enable_flag", "0");
bool flag = DBHelper.BatchUpdateDataByIn("批量删除人员", "sys_user", comField, "user_id", listField.ToArray());
if (flag)
{
UploadUserData(listField);
BindPageData();
if (dgvUser.Rows.Count > 0)
{
dgvUser.CurrentCell = dgvUser.Rows[0].Cells[0];
}
MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
LocalCache._Update(CacheList.User);
}
else
{
MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
示例11: SelectGroups
protected override TestGroup[] SelectGroups(TestNode testNode)
{
List<TestGroup> groups = new List<TestGroup>();
foreach (XmlNode node in testNode.Xml.SelectNodes("properties/property[@name='Category']"))
{
var groupName = node.Attributes["value"].Value;
var group = Groups.Find((g) => g.Name == groupName);//GetGroup(groupName);
if (group == null)
{
group = new TestGroup(groupName);
Groups.Add(group);
groups.Add(group);
}
}
if (groups.Count == 0)
groups.Add(Groups[0]);
return groups.ToArray();
}
示例12: SqlBulkByTransNoLogNoBackUp
/// <summary> SQLBulk方式操作带事务无操作备份
/// </summary>
/// <param name="connStr">数据库连接串</param>
/// <param name="tableName">表名</param>
/// <param name="listRow">DataRowList集合</param>
/// <returns>SQLBulk批处理方式操作带事务,执行结果。全部成功,返回Bool True; 否则,返回False。</returns>
public static bool SqlBulkByTransNoLogNoBackUp(string connStr, string tableName, List<DataRow> listRow)
{
if (listRow.Count == 0)
{
return true;
}
using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();
SqlTransaction tran = conn.BeginTransaction();
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn, SqlBulkCopyOptions.CheckConstraints, tran))
{
bulkCopy.DestinationTableName = tableName;
bulkCopy.BulkCopyTimeout = 300;
DataTable dt = listRow[0].Table;
foreach (DataColumn dc in dt.Columns)
{
bulkCopy.ColumnMappings.Add(dc.ColumnName, dc.ColumnName);
}
try
{
bulkCopy.WriteToServer(listRow.ToArray());
tran.Commit();
return true;
}
catch (Exception ex)
{
tran.Rollback();
throw ex;
}
finally
{
bulkCopy.Close();
tran.Dispose();
}
}
}
}
示例13: Update
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(Wgw_listEntity model)
{
StringBuilder strSql = new StringBuilder();
List<SqlParameter> parameters = new List<SqlParameter>();
strSql.Append("update Wgw_list set ");
if (!string.IsNullOrEmpty(model.typeone))
{
strSql.Append(" typeone = @typeone , ");
parameters.Add(new SqlParameter("@typeone", model.typeone));
}
if (!string.IsNullOrEmpty(model.typetwo))
{
strSql.Append(" typetwo = @typetwo , ");
parameters.Add(new SqlParameter("@typetwo", model.typetwo));
}
if (true)
{
strSql.Append(" pid = @pid , ");
parameters.Add(new SqlParameter("@pid", model.pid));
}
if (true)
{
strSql.Append(" clientid = @clientid , ");
parameters.Add(new SqlParameter("@clientid", model.clientid));
}
if (!string.IsNullOrEmpty(model.listname))
{
strSql.Append(" listname = @listname , ");
parameters.Add(new SqlParameter("@listname", model.listname));
}
if (!string.IsNullOrEmpty(model.listdesc))
{
strSql.Append(" listdesc = @listdesc , ");
parameters.Add(new SqlParameter("@listdesc", model.listdesc));
}
if (true)
{
strSql.Append(" listorder = @listorder , ");
parameters.Add(new SqlParameter("@listorder", model.listorder));
}
if (!string.IsNullOrEmpty(model.listcover))
{
strSql.Append(" listcover = @listcover , ");
parameters.Add(new SqlParameter("@listcover", model.listcover));
}
strSql.Append(" isshow = @isshow , ");
parameters.Add(new SqlParameter("@isshow", model.isshow));
if (!string.IsNullOrEmpty(model.icon))
{
strSql.Append(" icon = @icon , ");
parameters.Add(new SqlParameter("@icon", model.icon));
} strSql = strSql.Remove(strSql.Length - 2, 2);
strSql.Append(" where [email protected] ");
parameters.Add(new SqlParameter("@id", model.id));
int rows = DBExecuteUtil.ExecuteSqlWithParams(strSql.ToString(), parameters.ToArray());
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
示例14: CreateNewActionReference
protected CodeExpression CreateNewActionReference(ActionTreeNode node, List<CodeExpression> actionArguments, List<string> actionArgumentTypes)
{
var actionArgumentRuntimeTypes = new List<CodeExpression>();
foreach (var type in actionArgumentTypes)
actionArgumentRuntimeTypes.Add(new CodeTypeOfExpression(source[type]));
CodeExpression createMethodSignature = new CodeObjectCreateExpression(
source[typeof (MethodSignature)],
new CodeExpression[]
{
new CodeTypeOfExpression(node.Controller.FullName),
new CodePrimitiveExpression(node.Name),
new CodeArrayCreateExpression(source[typeof (Type)], actionArgumentRuntimeTypes.ToArray())
});
var constructionArguments = new[]
{
new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), naming.ToMemberVariableName(serviceIdentifier)),
new CodeTypeOfExpression(node.Controller.FullName),
new CodePrimitiveExpression(node.Controller.Area),
new CodePrimitiveExpression(naming.ToControllerName(node.Controller.Name)),
new CodePrimitiveExpression(node.Name),
createMethodSignature,
new CodeArrayCreateExpression(source[typeof (ActionArgument)], actionArguments.ToArray())
};
return new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodePropertyReferenceExpression(
new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), naming.ToMemberVariableName(serviceIdentifier)),
"ControllerReferenceFactory"),
"CreateActionReference"),
constructionArguments);
}
示例15: SearchDruginfoList
public List<md_druginfo> SearchDruginfoList(string drugname, string standard, int producerid, string cust_name, string sub_name,
orderbyEnum? orderby, string orderbyCol, int pageIndex, int pageSize, out string error)
{
error = string.Empty;
try
{
#region Command
string selectSql = string.Format("select * from md_druginfo WHERE TRUE ");
StringBuilder conditionSb = new System.Text.StringBuilder();
List<MySqlParameter> paraList = new List<MySqlParameter>();
#endregion
#region 搜索条件
if (!string.IsNullOrEmpty(drugname))
{
conditionSb.Append(" AND drugname LIKE CONCAT('%', @drugname, '%') ");
paraList.Add(new MySqlParameter("drugname", drugname));
}
if (!string.IsNullOrEmpty(standard))
{
conditionSb.Append(" AND standard LIKE CONCAT('%', @standard, '%') ");
paraList.Add(new MySqlParameter("standard", standard));
}
if (producerid > 0)
{
conditionSb.Append("AND producerid = @producerid");
paraList.Add(new MySqlParameter("producerid", producerid));
}
if (!string.IsNullOrEmpty(cust_name))
{
conditionSb.Append(" AND cust_name LIKE CONCAT('%', @cust_name, '%') ");
paraList.Add(new MySqlParameter("cust_name", cust_name));
}
if (!string.IsNullOrEmpty(sub_name))
{
conditionSb.Append(" AND sub_name LIKE CONCAT('%', @sub_name, '%') ");
paraList.Add(new MySqlParameter("sub_name", sub_name));
}
#endregion
#region 排序 分页
string orderbyStr = string.Empty;
if (!string.IsNullOrEmpty(orderbyCol) && orderby.HasValue)
orderbyStr = orderbyFormat.getSortStr(orderby.Value, orderbyCol);
else
orderbyStr = " order by pkid ";
selectSql += conditionSb.ToString() + orderbyStr;
if (pageIndex > 0)
{
selectSql += " LIMIT @pageIndex , @pageSize ";
paraList.Add(new MySqlParameter("pageIndex", (pageIndex - 1) * pageSize));
paraList.Add(new MySqlParameter("pageSize", pageSize));
}
#endregion
#region 执行
var resultList = sqlHelper.ExecuteObjects<md_druginfo>(selectSql, paraList.ToArray()).ToList();
return resultList;
#endregion
}
catch (Exception ex)
{
error += BaseTool.FormatExceptionMessage(ex);
return null;
}
}