本文整理汇总了C#中Entities.List类的典型用法代码示例。如果您正苦于以下问题:C# List类的具体用法?C# List怎么用?C# List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
List类属于Entities命名空间,在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCategory
// Get all categories of products
public List<Category> GetCategory()
{
try
{
List<Category> ListOfCategory = new List<Category>();
connect = new Connection().Connect;
connect.Open();
Command = new SqlCommand("sp_getAllCategory", connect);
Command.CommandType = System.Data.CommandType.StoredProcedure;
SqlDataReader dr = Command.ExecuteReader();
while (dr.Read())
{
Category objCategory = new Category();
objCategory.CategoryID = dr.GetInt32(0);
objCategory.CategoryName = dr.GetString(1);
ListOfCategory.Add(objCategory);
}
connect.Close();
return ListOfCategory;
}
catch (Exception)
{
connect.Close();
return null;
}
}
示例2: GetHsql
public override IQuery GetHsql(Object data)
{
StringBuilder sql = new StringBuilder("select a from C_CasNumber a where ");
C_CasNumber C_CasNumber = (C_CasNumber)data;
if (C_CasNumber != null)
{
Parms = new List<Object[]>();
if (C_CasNumber.CasNumberID != 0)
{
sql.Append(" a.CasNumberID = :id and ");
Parms.Add(new Object[] { "id", C_CasNumber.CasNumberID });
}
if (!String.IsNullOrEmpty(C_CasNumber.Name))
{
sql.Append(" (a.Name like :nom OR a.Code like :nomz) and ");
Parms.Add(new Object[] { "nom", "%" + C_CasNumber.Name + "%" });
Parms.Add(new Object[] { "nomz", C_CasNumber.Name + "%" });
}
if (!String.IsNullOrEmpty(C_CasNumber.Code))
{
sql.Append(" a.Code = :nom1 and ");
Parms.Add(new Object[] { "nom1", C_CasNumber.Code });
}
}
sql = new StringBuilder(sql.ToString());
sql.Append(" 1=1 order by a.CasNumberID asc ");
IQuery query = Factory.Session.CreateQuery(sql.ToString());
SetParameters(query);
return query;
}
示例3: BuildBetTeam
#pragma warning disable 1587
/// <summary>
/// Set bet team to template by ticket bet team pattern with following rules:
/// <para>ho: Home and Over, hu: Home and Under</para>
/// <para>ao: Away and Over, au: Away and Under</para>
/// <para>do: Draw and Over, du: Draw and Over</para>
/// </summary>
/// <param name="ticket"> Ticket with bet type id is 143.</param>
/// <param name="ticketHelper"> Not null ticket helper.</param>
/// <param name="ticketData"> Not need this.</param>
#pragma warning restore 1587
protected override void BuildBetTeam(ITicket ticket, ITicketHelper ticketHelper, List<ITicketData> ticketData)
{
var teamName = string.Empty;
// Bet team pattern length is always 2
if (ticket.BetTeam.Length == 2)
{
switch (ticket.BetTeam[0])
{
case 'h':
teamName = ticketHelper.GetTeamNameById(ticket.HomeId);
break;
case 'a':
teamName = ticketHelper.GetTeamNameById(ticket.AwayId);
break;
case 'd':
teamName = CoreBetList.draw;
break;
}
var resultOverUnder = (ticket.BetTeam[1].ToString(CultureInfo.InvariantCulture) == BetTeamValue.O)
? CoreBetList.over
: CoreBetList.under;
Template.betTeam = string.Join(" & ", new string[] { teamName, resultOverUnder });
}
}
示例4: GetTopTenWorstMovies
public List<Movie> GetTopTenWorstMovies()
{
using (var ctx = new DatabaseContext())
{
var bests = (from r in ctx.Review
group r by r.MovieId into groupIds
select new { groupIds.Key, Average = groupIds.Sum(x => x.Note) / groupIds.Count() })
.OrderByDescending(x => x.Average)
.Take(10)
.ToList();
var worst = (from r in ctx.Review
group r by r.MovieId into groupIds
select new { groupIds.Key, Average = groupIds.Sum(x => x.Note) / groupIds.Count() })
.ToList()
.Where(r => !bests.Any(y => y.Key == r.Key))
.OrderBy(x => x.Average)
.Take(10)
.ToList();
var listWorst = new List<Movie>();
foreach (var movie in worst)
listWorst.Add(GetById(movie.Key));
return listWorst;
}
}
示例5: getAuthors
public static List<Yazar> getAuthors()
{
List<Yazar> Value = new List<Yazar>();
SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
SqlCommand cmd = new SqlCommand("select * from dbo.Yazar", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32(0);
string adi = reader.GetString(1);
string soyadi = reader.GetString(2);
Yazar Current = new Yazar(id, adi, soyadi);
string ozgecmis;
try
{
ozgecmis = reader.GetString(3);
}
catch(SqlNullValueException snve)
{
ozgecmis = "";
}
Current.Ozgecmis = ozgecmis;
Value.Add(Current);
}
reader.Close();
con.Close();
return Value;
}
示例6: BookList
/// <summary>
/// Constructor with user's way keeping
/// </summary>
/// <param name="repository">Object describing storage kind</param>
public BookList(IRepository repository)
{
if (repository == null)
throw new ArgumentNullException("Repository is undefined");
books = new List<Book>();
this.repository = repository;
}
示例7: FillTeams
public List<Team> FillTeams(Team homeTeam, Team awayTeam)
{
List<Team> teams = new List<Team>();
teams.Add(homeTeam);
teams.Add(awayTeam);
return teams;
}
示例8: GetAllComplejos
public IQueryable<ComplejoModelResponse> GetAllComplejos()
{
try
{
var complejos = from complejo in complejoRepository.All
select complejo;
List<ComplejoModelResponse> list = new List<ComplejoModelResponse>();
list.Add(new ComplejoModelResponse()
{
HttpStatusCode = 200,
HttpStatusDesc = "Ok",
Complejos = complejos
});
return list.AsQueryable();
}
catch (Exception ex)
{
List<ComplejoModelResponse> list = new List<ComplejoModelResponse>();
list.Add(new ComplejoModelResponse()
{
HttpStatusCode = 400,
HttpStatusDesc = "Bad Request",
Complejos = new List<Complejo>().AsQueryable(),
Exception = ex
});
return list.AsQueryable();
}
}
示例9: BuildBetTeam
protected override void BuildBetTeam(ITicket ticket, ITicketHelper ticketHelper, List<ITicketData> ticketData)
{
var betTeam = string.Empty;
switch (ticket.BetTeam)
{
case "0:0":
betTeam = CoreBetList.NoGoalBetType14;
break;
case "1:1":
betTeam = CoreBetList.HomeFG;
break;
case "1:2":
betTeam = CoreBetList.HomeLG;
break;
case "2:1":
betTeam = CoreBetList.AwayFG;
break;
case "2:2":
betTeam = CoreBetList.AwayLG;
break;
}
Template.betTeam = betTeam;
}
示例10: Select
public IList<KitAssembly> Select(KitAssembly data, int showRegs)
{
IList<KitAssembly> datos = new List<KitAssembly>();
/*
datos = GetHsql(data).List<KitAssembly>();
if (!Factory.IsTransactional)
Factory.Commit();
return datos;
*/
try
{
if (showRegs > 0)
datos = GetHsql(data).SetMaxResults(showRegs).List<KitAssembly>();
else
datos = GetHsql(data).List<KitAssembly>();
if (!Factory.IsTransactional)
Factory.Commit();
}
catch (Exception e)
{
NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e));
}
return datos;
}
示例11: GetHsql
public override IQuery GetHsql(Object data)
{
StringBuilder sql = new StringBuilder("select a from NodeRoute a where ");
NodeRoute noderoute = (NodeRoute)data;
if (noderoute != null)
{
Parms = new List<Object[]>();
if (noderoute.RowID != 0)
{
sql.Append(" a.RowID = :id and ");
Parms.Add(new Object[] { "id", noderoute.RowID });
}
if (noderoute.NextNode != null && noderoute.NextNode.NodeID != 0)
{
sql.Append(" a.NextNode.NodeID = :id1 and ");
Parms.Add(new Object[] { "id1", noderoute.NextNode.NodeID });
}
if (noderoute.CurNode != null && noderoute.CurNode.NodeID != 0)
{
sql.Append(" a.CurNode.NodeID = :id2 and ");
Parms.Add(new Object[] { "id2", noderoute.CurNode.NodeID });
}
}
sql = new StringBuilder(sql.ToString());
sql.Append("1=1 order by a.RowID asc ");
IQuery query = Factory.Session.CreateQuery(sql.ToString());
SetParameters(query);
return query;
}
示例12: BuildBetTeam
protected override void BuildBetTeam(ITicket ticket, ITicketHelper ticketHelper, List<ITicketData> ticketData)
{
string team = ticket.BetTeam != null && ticket.BetTeam.Contains(BetTeamValue.H) ? Template.Match.homeTeam : Template.Match.awayTeam;
string yesNo = ticket.BetTeam != null && ticket.BetTeam.Contains(BetTeamValue.Y) ? CoreBetList.lblYes : CoreBetList.lblNo;
Template.betTeam = string.Join(null, new string[] { team, " <span class=\"", Favorite, "\">", yesNo.ToUpper(), "</span>" });
}
示例13: getExamplePersons
public List<Person> getExamplePersons()
{
List<Person> PERSON = null;
try
{
CONNECTION.Open();
String query = "SELECT TOP 100 [FirstName],[MiddleName],[LastName] FROM [Person].[Person]";
COMMAND = new SqlCommand(query, CONNECTION);
READER = COMMAND.ExecuteReader();
if (READER.HasRows)
{
PERSON = new List<Person>();
EntityMapper MAPPER = new EntityMapper();
while (READER.Read())
PERSON.Add(MAPPER.convertToPerson(READER));
}
CONNECTION.Close();
}
catch (Exception EX)
{
errorMessage = EX.Message;
Console.WriteLine("Error: " + EX.Message);
}
return PERSON;
}
示例14: getCategories
public static List<Kategori> getCategories()
{
List<Kategori> Value = new List<Kategori>();
SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
SqlCommand cmd = new SqlCommand("select * from dbo.Kategori", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
int id = reader.GetInt32(0);
string adi = reader.GetString(1);
Kategori Current = new Kategori(id, adi);
string aciklama;
try
{
aciklama = reader.GetString(2);
}
catch (SqlNullValueException snve)
{
aciklama = "";
}
Current.Aciklama = aciklama;
Value.Add(Current);
}
reader.Close();
con.Close();
return Value;
}
示例15: BuildBetTeam
/// <summary>
/// Builds the bet team.
/// </summary>
/// <param name="ticket">The ticket.</param>
/// <param name="ticketHelper">The ticket helper.</param>
/// <param name="ticketData">The ticket data.</param>
protected override void BuildBetTeam(ITicket ticket, ITicketHelper ticketHelper, List<ITicketData> ticketData)
{
string choice = ticket.BetTeam;
var betTeam = string.Empty;
switch (choice)
{
case "01":
betTeam = "4 " + CoreBetList.points;
break;
case "02":
betTeam = "5 " + CoreBetList.points;
break;
case "03":
betTeam = "6 " + CoreBetList.points;
break;
case "04":
betTeam = "7 " + CoreBetList.upPoints;
break;
}
// " " because export format
Template.betTeam = HtmlCharacters.NoneBreakingSpace + betTeam;
}