本文整理汇总了C#中Model.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRecommendations
public static List<Movie> GetRecommendations(List<Movie> all, Dictionary<int, int> newRanks, List<Tuple<int, int, float>> oldRanks)
{
int newUserId = 0;
Ratings ratings = new Ratings();
foreach (var r in oldRanks)
{
ratings.Add(r.Item1, r.Item2, r.Item3);
if (r.Item1 > newUserId) newUserId = r.Item1;
}
// this makes us sure that the new user has a unique id (bigger than all other)
newUserId = newUserId + 1;
foreach (var k in newRanks)
{
ratings.Add(newUserId, k.Key, (float)k.Value);
}
var engine = new BiPolarSlopeOne();
// different algorithm:
// var engine = new UserItemBaseline();
engine.Ratings = ratings;
engine.Train(); // warning: this could take some time!
return all.Select(m =>
{
m.Rank = engine.Predict(newUserId, m.Id); // do the prediction!
return m;
}).ToList();
}
示例2: GetDoctorByIds
public List<md_docter> GetDoctorByIds(List<string> ids)
{
string id = string.Join(",", ids.Select(t => t));
string sql = @"SELECT *
FROM md_docter
where FIND_IN_SET(pkid,@ids)";
List<md_docter> resultlist = sqlHelper.ExecuteObjects<md_docter>(sql, new MySqlParameter("ids", id));
return resultlist;
}
示例3: SelectTests
public async Task<List<TestNodeAssembly>> SelectTests(List<string> testAssemblies = null)
{
var testsRootNode = await _testsTask;
testsRootNode.IsIncluded = true;
if(testAssemblies != null)
{
return testsRootNode.TestNodeAssemblies.Where(a =>
testAssemblies.Select(Path.GetFileNameWithoutExtension).Contains(a.Name)).ToList();
}
else
{
return testsRootNode.TestNodeAssemblies.ToList();
}
}
示例4: GetCouponsDetailByIds
public List<promotion_coupons_detail> GetCouponsDetailByIds(List<int> ids)
{
string id = string.Join(",", ids.Select(t => t));
string sql = @"SELECT *
FROM promotion_coupons_detail
where FIND_IN_SET(pkid,@ids)";
List<promotion_coupons_detail> resultlist = sqlHelper.ExecuteObjects<promotion_coupons_detail>(sql, new MySqlParameter("ids", id));
return resultlist;
}
示例5: ToDto
private List<UsuarioDto> ToDto(List<Usuario> usuarios)
{
return usuarios.Select(u => new UsuarioDto {Login = u.Login, Saldo = u.Saldo}).ToList();
}
示例6: SelectMonth
private void SelectMonth()
{
DateTime now = new DateTime(int.Parse(this.YearDropDownList.SelectedValue), 1, 1);
DateTime startMonth = new DateTime(now.Year, 1, 1);
List<DateTime> months = new List<DateTime>(12);
for (int i = 0; i < 12; i++)
{
months.Add(startMonth.AddMonths(i));
}
this.MonthDropDownList.DataSource = months.Select(m => new { MonthText = m.ToString("MMMM"), m.Month });
this.MonthDropDownList.DataBind();
this.SelectDay();
}
示例7: PerformRandomFlight
private int[] PerformRandomFlight(int[] xi, double alfa)
{
int[] result = new int[n];
xi.CopyTo(result, 0);
if(alfa < 0 || alfa >= n ) throw new Exception("Zla alfa");
var rand = new Random();
int nrOfElementsToShuffle = (int) (alfa*rand.NextDouble());
//choosing elements to be shuffled
var positionsToShuffle = new List<int>();
var needed = nrOfElementsToShuffle;
var available = n;
while (positionsToShuffle.Count < nrOfElementsToShuffle) {
if( rand.NextDouble() < ((double)needed / available) )
{
positionsToShuffle.Add(xi[available - 1]);
needed--;
}
available--;
}
//CHANGEME
//shuffling them
var valuesLeft = positionsToShuffle.Select(i => xi[i]).ToList();
int left = nrOfElementsToShuffle;
foreach (int i in positionsToShuffle)
{
result[i] = valuesLeft[rand.Next(left)];
// valuesLeft.Remove(xi[i]);
valuesLeft.Remove(result[i]);
left--;
}
if(left != 0) throw new Exception("nie powinnno nic zostac!");
return result;
}