本文整理汇总了C#中Data.List.First方法的典型用法代码示例。如果您正苦于以下问题:C# List.First方法的具体用法?C# List.First怎么用?C# List.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.List
的用法示例。
在下文中一共展示了List.First方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllUpdatesFromEmail
/// <summary>
/// Gets all StatusUpdate objects which came from a particular ProjectUpdate(email)
/// </summary>
/// <param name="projectUpdateID">Guid which is the unique identifer for the ProjectUpdate being queried</param>
/// <returns>List of StatusUpdate objects</returns>
public List<StatusUpdate> GetAllUpdatesFromEmail(Guid projectUpdateID)
{
var updates = new List<StatusUpdate>();
updates = context.StatusUpdates.Where(su => su.ProjectUpdateID == projectUpdateID).ToList();
if (updates.Count > 0)
{
Guid projectID = updates.First().ProjectID;
string projectName = context.Projects.FirstOrDefault(p => p.ProjectID == projectID).ProjectName;
foreach (StatusUpdate update in updates)
{
update.ProjectName = projectName;//__now also write ProjectName to each update
}
}
return updates;
}
示例2: worker_RunWorkerCompleted
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
IList<ArbitrageItem> resultsToDataGrid = new List<ArbitrageItem>();
foreach (var item in background.arbitrageList.OrderByDescending(x => x.PercentBenefit))
{
resultsToDataGrid.Add(item);
}
if (resultsToDataGrid.Count > 0)
dataGridView1.ColumnHeadersVisible = true;
dataGridView1.Columns["PercentBenefit"].DefaultCellStyle.Format = "###.##########";
dataGridView1.DataSource = resultsToDataGrid;
toolStripStatusInfo.Text = Resources.Ready;
if (isLoop != true)
{
button1.Enabled = true;
button2.Enabled = true;
}
else
{
button1.Enabled = false;
button2.Enabled = true;
}
if (background.arbitrageList.Count > 0)
{
dataGridView1.Visible = true;
if (Options.Instance.SoundNotification == true && FormWindowState.Normal == this.WindowState)
{
var player = new System.Media.SoundPlayer();
player.Stream = Resources.doorbell;
player.Play();
}
if (Options.Instance.DisplayBalloonWhenPercentChanges == true && FormWindowState.Minimized == this.WindowState)
{
var BallonText = String.Format("Best offer brings you {0}% of benefit",resultsToDataGrid.First().PercentBenefit.ToString("##.######"));
if (earlierBallonText.Equals(BallonText) == false)
{
notifyIcon1.BalloonTipText = BallonText;
earlierBallonText = BallonText;
if(Options.Instance.HideBalloonAfter5thDisplay==false && balloonCounter<5)
if (Options.Instance.SoundNotification == true)
{
var player = new System.Media.SoundPlayer();
player.Stream = Resources.doorbell;
player.Play();
notifyIcon1.ShowBalloonTip(1500);
}
else
notifyIcon1.ShowBalloonTip(1500);
balloonCounter++;
}
}
}
}
示例3: agregarFacturas
public static void agregarFacturas(List<FactUI> facturas)
{
// if (facturas.Count > 0)
CatalogoFacturas.addFacturas(facturas, facturas.First().edificio, DateTime.Parse(facturas.First().fecha));
}
示例4: PopulateTimelineData
private static void PopulateTimelineData(List<ItemsViewModel> itemsDataP11, List<ItemsViewModel> itemsDataP14, List<DataItemViewModel> timelineData)
{
#region Rabadon
IList<DataItemViewModelAux> divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Rabadon"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Rabadon"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Needlessly
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Needlessly"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Needlessly"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Zhonya
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Zhonya"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Zhonya"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Luden's Echo
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Luden"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Luden"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
}
示例5: addFacturas
public static void addFacturas(List<FactUI> facturas, string edificio, DateTime periodo)
{
try
{
admEntities db = Datos.getDB();
//List<factura> facturasExistentes = db.factura.ToList();
//foreach (FactUI f in facturas)
//{
// bool update = false;
// foreach (factura fEx in facturasExistentes)
// {
// if (f.id != null)
// {
// if (fEx.idfactura == int.Parse(f.id))
// {
// fEx.detalle = f.detalle;
// fEx.fecha = DateTime.Parse(f.fecha);
// fEx.id_sector = f.sector.idsector;
// fEx.id_tipogasto = f.gasto.idtipo_gasto;
// fEx.importe = double.Parse(f.importe);
// fEx.numero_factura = f.nroFactura;
// if (f.provedor != null)
// fEx.razon_provedor = f.provedor.razon_social;
// db.Entry(fEx).State = System.Data.EntityState.Modified;
// update = true;
// break;
// }
// }
// }
// if (update == false)
// {
// factura fact = new factura();
// fact.dir_edificio = f.edificio;
// fact.fecha = DateTime.Parse(f.fecha);
// fact.id_sector = f.sector.idsector;
// fact.id_tipogasto = f.gasto.idtipo_gasto;
// fact.importe = double.Parse(f.importe);
// fact.numero_factura = f.nroFactura;
// if (f.provedor != null)
// fact.razon_provedor = f.provedor.razon_social;
// fact.detalle = f.detalle;
// db.factura.Add(fact);
// }
//}
List<factura> facturasExistentes = db.factura.Where(x => x.dir_edificio == edificio && x.fecha.Month == periodo.Month && x.fecha.Year == periodo.Year).ToList();
foreach (factura f in facturasExistentes)
db.factura.Remove(f);
if (facturas.First().sector == null)
{
db.SaveChanges();
return;
}
foreach (FactUI f in facturas)
{
factura fact = new factura();
fact.dir_edificio = f.edificio;
fact.fecha = DateTime.Parse(f.fecha);
fact.id_sector = f.sector.idsector;
fact.id_tipogasto = f.gasto.idtipo_gasto;
fact.importe = double.Parse(f.importe);
fact.numero_factura = f.nroFactura;
if (f.provedor != null)
fact.razon_provedor = f.provedor.razon_social;
fact.detalle = f.detalle;
db.factura.Add(fact);
}
db.SaveChanges();
}
catch (Exception e)
{
Logger.Log.write(e.InnerException == null ? e.Message : e.InnerException.Message);
throw e;
}
}