本文整理汇总了C#中List.Join方法的典型用法代码示例。如果您正苦于以下问题:C# List.Join方法的具体用法?C# List.Join怎么用?C# List.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.Join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractReportData
public override DataMatrix ExtractReportData(IProgressObserver progress)
{
var service = new TaxaService(User);
progress.ProgressStart(String.Format("Preparing Darwin Core records for {0} specimens...", _idSet.Count));
DataMatrix result = null;
var idSet = new LinkedList<int>(_idSet);
int chunkSize = 2000;
var helper = new DarwinCoreReportHelper();
var chunk = new List<int>();
var count = 0;
while (idSet.Count > 0) {
chunk.Add(idSet.First.Value);
idSet.RemoveFirst();
count++;
if (chunk.Count >= chunkSize || idSet.Count == 0) {
var percentComplete = ((double) count / (double) _idSet.Count) * 100;
progress.ProgressMessage(String.Format("Preparing Darwin Core records {0} of {1}", count, _idSet.Count), percentComplete);
var where = "tblMaterial.intMaterialID in (" + chunk.Join(",") + ")";
var dataChunk = helper.RunDwcQuery(service, where);
if (result == null) {
result = dataChunk;
} else {
result.AppendMatrix(dataChunk);
}
chunk = new List<int>();
}
}
progress.ProgressEnd(String.Format("{0} Darwin Core records retrieved.", count));
return result;
}
示例2: JoinEx1
public static void JoinEx1()
{
Person magnus = new Person { Name = "Hedlund, Magnus" };
Person terry = new Person { Name = "Adams, Terry" };
Person charlotte = new Person { Name = "Weiss, Charlotte" };
Pet barley = new Pet { Name = "Barley", Owner = terry };
Pet boots = new Pet { Name = "Boots", Owner = terry };
Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
Pet daisy = new Pet { Name = "Daisy", Owner = magnus };
List<Person> people = new List<Person> { magnus, terry, charlotte };
List<Pet> pets = new List<Pet> { barley, boots, whiskers, daisy };
// Create a list of Person-Pet pairs where
// each element is an anonymous type that contains a
// Pet's name and the name of the Person that owns the Pet.
var query =
people.Join(pets,
person => person,
pet => pet.Owner,
(person1, pet1) =>
new { OwnerName = person1.Name, Pet = pet1.Name });
foreach (var obj in query)
{
Console.WriteLine(
"{0} - {1}",
obj.OwnerName,
obj.Pet);
}
}
示例3: Frm_Main_Load
private void Frm_Main_Load(object sender, EventArgs e)
{
List<SaleBill> bills = new List<SaleBill>//创建销售单列表
{
new SaleBill("XS001","王*科",Convert.ToDateTime("2010-1-1")),
new SaleBill("XS002","王*军",Convert.ToDateTime("2010-2-1")),
new SaleBill("XS003","赵*东",Convert.ToDateTime("2010-3-1"))
};
List<SaleProduct> products = new List<SaleProduct>//创建销售商品列表
{
new SaleProduct("XS001","冰箱",1,2000),
new SaleProduct("XS001","洗衣机",2,600),
new SaleProduct("XS002","电暖风",3,50),
new SaleProduct("XS002","吸尘器",4,200),
new SaleProduct("XS003","手机",1,990)
};
//关联销售单列表和销售商品列表
var query= bills.Join(products,
b => b.SaleBillCode,
p => p.SaleBillCode,
(b, p) => new
{
销售单号 = b.SaleBillCode,
销售日期 = b.SaleDate,
销售员 = b.SaleMan,
商品名称 = p.ProductName,
数量 = p.Quantity,
单价 = p.Price,
金额 = p.Quantity * p.Price
});
dataGridView1.DataSource = query.ToList();//数据绑定
}
示例4: ErrorCallNotFound
public static void ErrorCallNotFound(this Log log, Location location, Type funcType, List<Type> argTypes)
{
if (funcType is ErrorType || argTypes.Exists(x => x is ErrorType)) {
return;
}
log.Error(location, "cannot call " + WrapType(funcType) + " with arguments \"(" + argTypes.Join() + ")\"");
}
示例5: grid_NeedDataSource
protected void grid_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (combo.SelectedIndex == -1)
{
grid.DataSource = new List<HousingLog>();
}
else
{
var gid = Guid.Parse(combo.SelectedValue);
var id = Guid.Parse(combo.SelectedValue).ToString().ToUpper();
var list = new List<HousingLog>();
var st = from.SelectedDate.HasValue ? from.SelectedDate.Value : DateTime.MinValue;
var et = to.SelectedDate.HasValue ? to.SelectedDate.Value : DateTime.Today;
if (st > et)
{
var tt = st;
st = et;
et = tt;
}
et = et.AddDays(1).AddMilliseconds(-1);
var uid = Guid.Parse(Session["MemberId"].ToString());
var root = db.Value.Housing_Member.Count(o => o.UserId == uid && o.DepartmentId == Guid.Empty) > 0;
using (IStorageEngine engine = STSdb.FromFile(Server.MapPath(string.Format("App_Data/Housing_{0}.record.queryx", id))))
{
var table = engine.OpenXTablePortable<Guid, HousingLog>("Record");
list = table.Where(o => o.Value.时间 >= st && o.Value.时间 <= et).OrderByDescending(o => o.Value.时间).Select(o => o.Value).ToList();
}
//if (!root)
//{
list = list.Join(db.Value.Housing_Member.Where(x => x.DepartmentId != Guid.Empty), o => o.用户ID, o => o.UserId, (a, b) => a).ToList();
//}
grid.DataSource = list;
}
}
示例6: Main
static void Main()
{
Person Ivan = new Person{ Name = "Ivan Petrov" };
Person Gosho = new Person{ Name = "Gosho Georgiev" };
Person Mara = new Person{ Name = "Kaka Mara" };
Pet barley = new Pet{ Name = "Barley", Owner = Ivan };
Pet boots = new Pet{ Name = "Boots", Owner = Ivan };
Pet whiskers = new Pet{ Name = "Whiskers", Owner = Mara };
Pet daisy = new Pet{ Name = "Daisy", Owner = Gosho };
List<Person> people = new List<Person>{ Ivan, Gosho, Mara };
List<Pet> pets = new List<Pet>{ barley, boots, whiskers, daisy };
var query =
//from person in people
// join p in pets on person equals p.Owner
// select new { OwnerName = person.Name, Pet = p.Name };
people.Join(pets, person => person,
pet => pet.Owner,
(person, pet) =>
new { OwnerName = person.Name, Pet = pet.Name });
foreach (var obj in query)
{
Console.WriteLine("{0} - {1}",
obj.OwnerName,
obj.Pet);
}
}
示例7: PathTemplateProcessor
public PathTemplateProcessor(string path)
{
var segments = new List<PathSegment>();
var searchPath = new List<string>();
var pathSegments = path.Split(new[] { '/', '\\' });
if (pathSegments[0] != "**")
segments.Add(new WildcardPathSegment());
foreach (var seg in pathSegments)
{
var templateSegment = TemplatePathSegment.TryParse(seg);
PathSegment segment;
string searchSegment;
if (seg == "**")
{
segment = new WildcardPathSegment();
searchSegment = "**";
}
else if (templateSegment != null)
{
segment = templateSegment;
searchSegment = "*";
}
else
{
segment = new LiteralPathSegment(seg);
searchSegment = seg;
}
segments.Add(segment);
searchPath.Add(searchSegment);
}
_segments = new LinkedList<PathSegment>(segments);
_searchString = searchPath.Join(System.IO.Path.DirectorySeparatorChar);
}
示例8: Main
static void Main(string[] args)
{
// LINQ Using join
string[] popularProductNames = { "A", "B" };
var products = new List<Product>() {
new Product() { Name = "A"},
new Product() { Name = "A"},
new Product() { Name = "B"},
new Product() { Name = "C"},
};
// Query syntax
var qresult = from p in products
join n in popularProductNames on p.Name equals n
select p;
Console.WriteLine("Query syntax: {0}", string.Join(", ", qresult.Select(p => p.Name)));
// Extension syntax
var eresult = products.Join(popularProductNames, p => p.Name, pp => pp, (p,pp) => p);
Console.WriteLine("Extension syntax: {0}", string.Join(", ", eresult.Select(p => p.Name)));
Console.ReadLine();
}
示例9: LoadDefaults
public void LoadDefaults(CachedUse use)
{
tid.Value = use.UserTarget;
var catalogs = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
if (CurrentStore.State == StoreState.食品)
{
catalogs.RemoveAll(o => o.ParentId == null && o.Name != use.UserTarget);
catalog.DataSource = catalogs;
catalog.DataBind();
catalog.EmbeddedTree.Nodes[0].Expanded = true;
}
else
{
catalog.DataSource = catalogs;
catalog.DataBind();
}
var ____a = (double?)use.Amount;
note.Text = use.Note;
if (use.CatalogId.HasValue && use.CatalogId.Value != Guid.Empty)
{
var catalogId = use.CatalogId.Value;
var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString());
node.Selected = true;
node.ExpandParentNodes();
catalog.SelectedValue = catalogId.ToString();
var c = db.Value.StoreCatalog.Single(o => o.Id == catalogId);
var list = new List<Guid>();
AddChildren(list, c);
obj.DataSource = list.Join(db.Value.StoreObject, o => o, o => o.CatalogId, (a, b) => b).OrderBy(o => o.Ordinal).ToList();
obj.DataBind();
if (use.ObjectId.HasValue && use.ObjectId.Value != Guid.Empty)
{
var oid = use.ObjectId.Value;
var so = db.Value.StoreObject.Single(o => o.Id == oid);
unit.Text = so.Unit;
specification.Text = so.Specification;
stored.Text = so.Amount.ToAmount();
obj.SelectedIndex = obj.FindItemIndexByValue(use.ObjectId.ToString());
amount.Value = ____a.HasValue ? ____a.Value : (double)so.Amount;
if (so.Consumable)
{
act.DataSource = new[] { "领用" };
act.DataBind();
}
else
{
act.DataSource = new[] { "借用", "领用" };
act.DataBind();
}
if (!use.Type.Null())
{
act.FindItemByText(use.Type).Selected = true;
}
}
else
{
amount.Value = ____a;
}
}
}
示例10: InitializeHomoryPage
protected void InitializeHomoryPage()
{
var user = CurrentUser;
//visit.ImageUrl = user.Icon;
//visitTime.InnerText = DateTime.Now.ToString("HH:mm");
time.Text = string.Format("{0} {1}", DateTime.Today.ToString("MM月dd日"),
DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn")));
board.DataSource = user.Resource.Where(o => o.State == State.启用).OrderByDescending(o => o.Rate).Take(5).ToList();
board.DataBind();
var favouritesSource = HomoryContext.Value.UserFavourite.Where(o => o.State == State.启用 && o.UserId == CurrentUser.Id).ToList();
var favouritesSourceId = favouritesSource.Select(o => o.FavouriteUserId).ToList();
favourites.DataSource = favouritesSource.Select(o => o.FavouriteUser).Take(3).ToList();
favourites.DataBind();
relatives.DataSource =
HomoryContext.Value.User.Where(o => o.State < State.审核 && o.Type == UserType.教师 || o.Type == UserType.内置 || o.Type == UserType.注册).ToList().Where(o => !favouritesSourceId.Contains(o.Id)).Take(3).ToList();
relatives.DataBind();
var t1 = CurrentUser.GroupUser.Where(o => o.State < State.审核).ToList();
var t2 = t1.Where(o => o.Group.Type == GroupType.教研团队 && o.State < State.审核).ToList().Select(o=>o.GroupId).ToList();
var t3 = new List<Guid>();
foreach (var g in t2)
{
t3.AddRange(HomoryContext.Value.Catalog.Where(o=>o.TopId==g).Select(o=>o.Id).ToList());
}
var t4 = t3.Join(HomoryContext.Value.ViewResourceX, o => o, o => o.CatalogId, (a, b) => b.Id).ToList().Distinct();
groupRes.DataSource =
t4.Join(HomoryContext.Value.Resource, o => o, o => o.Id, (a, b) => b)
.OrderByDescending(o => o.Time)
.Take(5)
.ToList();
groupRes.DataBind();
}
示例11: HandleLine
private void HandleLine(Action<IList<string>> action, IList<string> lines)
{
foreach (var l in lines)
{
var match = ParseColumns.Match(l);
if (match.Success)
{
var captures = match.Groups[2].Captures;
var list = new List<string>(captures.Count);
list.Add(match.Groups[1].Value);
for (var i = 0; i < captures.Count; i++)
list.Add(captures[i].Value);
try
{
action(list);
}
catch
{
try
{
action(list);
}
catch
{
if (this.Info != null)
this.Info.Failed.Add(list.Join(" "));
}
}
}
}
}
示例12: LoadDefaults
public void LoadDefaults(CachedIn @in)
{
tid.Value = @in.TargetId.ToString();
var target = db.Value.StoreTarget.Single(o => o.Id == @in.TargetId);
var catalogs = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
if (CurrentStore.State == StoreState.食品)
{
catalogs.RemoveAll(o => o.ParentId == null && o.Name != target.UsageTarget);
catalog.DataSource = catalogs;
catalog.DataBind();
catalog.EmbeddedTree.Nodes[0].Expanded = true;
age.ReadOnly = true;
age.Text = target.UsageTarget;
place.Text = "{0}食堂".Formatted(target.UsageTarget.Substring(0, 2));
}
else
{
catalog.DataSource = catalogs;
catalog.DataBind();
age.ReadOnly = false;
age.Text = string.Empty;
}
amount.Value = (double?)@in.Amount;
perPrice.Value = (double?)@in.SourcePerPrice;
fee.Value = (double?)@in.Fee;
money.Value = (double?)@in.Money;
if ([email protected]Place.Null())
place.Text = @in.Place;
note.Text = @in.Note;
time.SelectedDate = (@in.TimeNode.HasValue ? @in.TimeNode.Value : target.TimeNode).ToTime();
if (@in.CatalogId.HasValue && @in.CatalogId.Value != Guid.Empty)
{
var catalogId = @in.CatalogId.Value;
var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString());
node.Selected = true;
node.ExpandParentNodes();
catalog.SelectedValue = catalogId.ToString();
var c = db.Value.StoreCatalog.Single(o => o.Id == catalogId);
var list = new List<Guid>();
AddChildren(list, c);
obj.DataSource = list.Join(db.Value.StoreObject, o => o, o => o.CatalogId, (a, b) => b).OrderBy(o => o.Ordinal).ToList();
obj.DataBind();
if (@in.ObjectId.HasValue && @in.ObjectId.Value != Guid.Empty)
{
var oid = @in.ObjectId.Value;
var so = db.Value.StoreObject.Single(o => o.Id == oid);
unit.Text = so.Unit;
specification.Text = so.Specification;
stored.Text = so.Amount.ToAmount();
obj.SelectedIndex = obj.FindItemIndexByValue(@in.ObjectId.ToString());
var last = so.StoreIn.OrderByDescending(o => o.AutoId).FirstOrDefault();
if (last != null)
{
perPrice.Value = (double)last.SourcePerPrice;
}
}
age.Text = @in.Age;
}
}
示例13: GenerateWorkItemClass
private static string GenerateWorkItemClass(WorkItem item)
{
var classes = new List<string> {"workitem"};
classes.AddRange(item.Classes);
return classes.Join(' ');
}
示例14: GetCallingArguments
public static string GetCallingArguments(IEnumerable<Expression> pArguments) {
List<string> values = new List<string>();
foreach (Expression expression in pArguments) {
values.Add(expression.Value);
}
return values.Join(", ");
}
示例15: InternalExecute
protected override long InternalExecute()
{
long iRows = 0L;
List<string> queryColumns = new List<string>();
SQLiteParameter idParam = new SQLiteParameter("@" + this._identityField, DbType.Int64);
Dictionary<string, SQLiteParameter> parametersCache = new Dictionary<string, SQLiteParameter>
{
{ this._identityField.ToUpper(), idParam }
};
if (this.TableDefinition != null)
{
foreach (FieldDefinition field in this.TableDefinition.Fields.Values)
{
parametersCache.Add(field.Name, new SQLiteParameter("@" + field.Name, field.SqlType.ToDbType()));
queryColumns.Add(field.Name.AsSqlClausePair());
}
string updateSql = queryColumns.Join(", ");
string sql = string.Format(
"UPDATE [{0}] SET {1} WHERE [{2}] = @{2};",
this.TableDefinition.Name,
updateSql,
this._identityField
);
Log.DebugFormat(
"update: Table: '{0}', Query: '{1}'",
this.TableDefinition.Name,
sql
);
foreach (ITableRow row in this._rows)
{
foreach (KeyValuePair<string, object> pair in row.Values)
{
if (parametersCache.ContainsKey(pair.Key))
{
parametersCache[pair.Key].Value = pair.Value;
}
}
idParam.Value = row.Values[this._identityField];
iRows = this.ExecuteNonQuery(
sql,
parametersCache.Values
);
}
}
this._rows.Clear();
return iRows;
}