本文整理汇总了C#中People.Select方法的典型用法代码示例。如果您正苦于以下问题:C# People.Select方法的具体用法?C# People.Select怎么用?C# People.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类People
的用法示例。
在下文中一共展示了People.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDatabasePeople
public static List<Models.Person> GetDatabasePeople(People results)
{
var netflixids = results.Select(p => p.Id);
using (FilmTroveContext ftc = new FilmTroveContext())
{
///1) find the matching records from the database
var matchedpeople = ftc.People.Where(m => netflixids.Contains(m.Netflix.Id));
///2) find the records that don't have a match
///select the ids and get the netflix Ids that aren't in the FT database
var ftnfids = matchedpeople.Select(m => m.Netflix.Id);
var netflixidsunmatched = netflixids.Where(m => !ftnfids.Contains(m));
//Int32 count = 0;
foreach (String nid in netflixidsunmatched)
{
///create FT database records for each of these with the movies basic information for now
FilmTrove.Models.Person newperson = ftc.People.Create();
FlixSharp.Holders.Person netflixperson = results.Find(nid);
FillBasicPerson(newperson, netflixperson);
//newperson.Name = netflixperson.Name;
//newperson.Bio = netflixperson.Bio;
//newperson.Netflix = new NetflixPersonInfo();
//newperson.Netflix.Id = netflixperson.Id;
//newperson.Netflix.IdUrl = netflixperson.IdUrl;
//newperson.Netflix.Url = netflixperson.NetflixSiteUrl;
ftc.People.Add(newperson);
}
try
{
//count =
ftc.SaveChanges();
}
catch (Exception)
{
throw;
///need to add some sort of logging?
}
//if (count > 0)
if (matchedpeople.Count() < results.Count())
matchedpeople = ftc.People.Where(m => netflixids.Contains(m.Netflix.Id));
//else
// return matchedpeople.ToList();
return results.Select(p =>
matchedpeople.First(f =>
f.Netflix.Id == p.Id)).ToList();
}
}