本文整理汇总了C#中Entities.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entities.List
的用法示例。
在下文中一共展示了List.Select方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MonsterEngine
public MonsterEngine(List<Monster> monsters, List<BaseEntity> surroundings)
{
List<MonsterAI> monsterAIs = monsters.Select(x => new MonsterAI(x, surroundings)).ToList();
this.ActiveMonsters = monsterAIs;
RegisterAIEvents();
activeThread = new Thread(AIOperation);
activeThread.IsBackground = true;
}
示例2: GetAllById
public IEnumerable<string> GetAllById(Guid id)
{
IEnumerable<GoalLog> goalLogs = database.GetTheDatabase().GoalLog.FindAllByGoalId(id).ToList<GoalLog>();
var accountIds = new HashSet<Guid>();
var domainEvents = new List<GoalDomainEvent>();
var accounts = new Dictionary<Guid, Account>();
foreach (var goalLog in goalLogs) {
var type = Type.GetType(goalLog.Event);
var goalDomainEvent = (GoalDomainEvent)JsonConvert.DeserializeObject(goalLog.Data, type);
accountIds.Add(goalDomainEvent.AccountId);
domainEvents.Add(goalDomainEvent);
}
foreach (var accountId in accountIds) {
accounts[accountId] = accountRepository.FindById(accountId);
}
return domainEvents.Select(domainEvent => domainEvent.GetMessage(accounts[domainEvent.AccountId])).ToList();
}
示例3: GetModelList
public List<TaskModel> GetModelList(List<Task> tasks)
{
return tasks.Select(GetModel).ToList();
}
示例4: Search
public IEnumerable<KeyValuePair<int, string>> Search(string customerName)
{
if (string.IsNullOrEmpty(customerName) || string.IsNullOrWhiteSpace(customerName))
{
yield return new KeyValuePair<int, string>();
}
var search = new CustomerSearch(new LevenshteinDistance());
IEnumerable<KeyValuePair<int, string>> values = new List<KeyValuePair<int, string>>();
if (_customerRespository.Persistence == Persistence.SQL)
{
values = _customerRespository.All.Select(i => new KeyValuePair<int, string>(i.Id, i.Name)).ToList();
}
else if (_customerRespository.Persistence == Persistence.Graph)
{
var graph = _customerRespository.GraphClient;
values = graph.Cypher.Match("(p:Customer)").Return(p => p.As<CustomerGraph.Node>()).Results
.Select(p => new KeyValuePair<int, string>((int)p.Id, p.Name));
}
foreach (var match in search.FindClosestMatches(customerName, values.Select(i => i.Value), 5))
{
yield return (new KeyValuePair<int, string>(values.First(c => c.Value == match).Key, match));
}
}
示例5: GetModelList
public List<TagsModel> GetModelList(List<Tag> tags)
{
return tags.Select(GetModel).ToList();
}
示例6: GetModelList
public List<UserModel> GetModelList(List<User> users)
{
return users.Select(GetModel).ToList();
}
示例7: LoginAsync
/// <summary>
/// 登录。如果返回异常则说明登录失败
/// </summary>
/// <param name="verifyPoints"></param>
/// <returns></returns>
public async Task<Exception> LoginAsync(string username, string password, List<Point> verifyPoints)
{
IsLogined = false;
LoginInfo = new LoginInfo()
{
UserName = username,
Password = password
};
var loginData = new Dictionary<string, string>()
{
["loginUserDTO.user_name"] = LoginInfo.UserName,
["userDTO.password"] = LoginInfo.Password,
["randCode"] = verifyPoints.Select(s => s.X + "," + s.Y).JoinAsString(",")
};
var loginCheck = NetClient.Create<WebResponseResult<LoginAsyncResult>>(
HttpMethod.Post,
"https://kyfw.12306.cn/otn/login/loginAysnSuggest",
"https://kyfw.12306.cn/otn/login/init",
loginData
);
await loginCheck.SendTask();
if (!loginCheck.IsValid())
{
return loginCheck.Exception ?? new Exception("未能提交请求");
}
if (!loginCheck.Result.Data.IsSuceess)
{
return new Exception(loginCheck.Result.GetErrorMessage());
}
//登录成功
var postLogin = NetClient.Create<string>(
HttpMethod.Post,
"https://kyfw.12306.cn/otn/login/userLogin",
"https://kyfw.12306.cn/otn/login/init"
);
await postLogin.SendTask(); //这里的返回值我们不care ....
//登录好了。等等。。我们好像想拿到显示的中文名?
//所以多加一个请求吧。
var realNameCtx = NetClient.Create<string>(
HttpMethod.Get,
"https://kyfw.12306.cn/otn/index/initMy12306",
"https://kyfw.12306.cn/otn/login/init"
);
await realNameCtx.SendTask();
if (realNameCtx.IsValid())
{
//匹配出名字信息
var realMatch = Regex.Match(realNameCtx.Result, @"user_name\s*=\s*['""]([^'""]+)['""]", RegexOptions.Singleline);
if (realMatch.Success)
{
LoginInfo.DisplayName = realMatch.GetGroupValue(1).DecodeFromJsExpression();
}
}
//这里失败了我们就随便起个名字,嗯。
if (LoginInfo.DisplayName.IsNullOrEmpty())
LoginInfo.DisplayName = "路人甲";
IsLogined = true;
return null;
}
示例8: GetAllCompanyVMByUser
public List<CompanyVM> GetAllCompanyVMByUser(int customerType, int userId)
{
User user = UserDAL.GetById(userId, new List<string> { "RelUserCompanies.Company" });
var companyList = new List<Company>();
foreach (var relCompany in user.RelUserCompanies)
{
if (!relCompany.IsDeleted && relCompany.Company.Type == customerType)
{
companyList.Add(relCompany.Company);
}
}
return companyList.Select(o => new CompanyVM
{
Id = o.Id,
Name = o.Name
}).ToList();
}