本文整理汇总了C#中ISession.Linq方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.Linq方法的具体用法?C# ISession.Linq怎么用?C# ISession.Linq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.Linq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDiplomacy
public virtual void SetDiplomacy(Group tribe, TribeDiplomate diplomacy, ISession session)
{
if ((this.TribePermission & TribePermission.DiplomateOfficer) != TribePermission.DiplomateOfficer)
return;
if (this.Group == tribe)
return;
if (diplomacy == TribeDiplomate.NoRelation)
{
object[] objects = { this.Group, tribe };
NHibernate.Type.IType[] types = { NHibernate.NHibernateUtil.GuessType(typeof(Group)), NHibernate.NHibernateUtil.GuessType(typeof(Group)) };
session.Delete(" from TribeRelation r where r.CurrentTribe=:current and r.DiplomaticTribe=:tribe", objects, types);
return;
}
TribeRelation oldRelation = (from tribeRelation in session.Linq<TribeRelation>()
where tribeRelation.CurrentTribe == this.Group
&& tribeRelation.DiplomaticTribe == tribe
select tribeRelation).SingleOrDefault<TribeRelation>();
if (oldRelation != null)
return;
TribeRelation relation = new TribeRelation();
relation.CurrentTribe = this.Group;
relation.DiplomaticTribe = tribe;
relation.Diplomacy = diplomacy;
session.Save(relation);
}
示例2: GetStaffGroupMembers
public IList<Player> GetStaffGroupMembers(Player staff, StaffGroup staffGroup, ISession session)
{
ServicesList.SecurityService.CheckPermission(staff, JobEnum.StaffGroupManagement.ToString(), "read");
return (from player in session.Linq<Player>()
where player.StaffGroups.Contains(staffGroup)
select player).ToList<Player>();
}
示例3: StaffAuthentication
public static int StaffAuthentication(string username, string password, ISession session)
{
return (from staff in session.Linq<Player>()
where (staff.Type == UserType.Administrator || staff.Type == UserType.Moderator)
&& staff.Username == username
&& staff.Password == Utilities.Encrypt(password)
select staff.ID).SingleOrDefault<int>();
}
示例4: AddMemberToStaffGroup
public void AddMemberToStaffGroup(Player currentStaff, string username, StaffGroup group, ISession session)
{
Player newStaff = (from player in session.Linq<Player>()
where player.Username == username
select player).SingleOrDefault<Player>();
if (newStaff == null)
return;
this.AddMemberToStaffGroup(currentStaff, newStaff, group, session);
}
示例5: Authentication
public int Authentication(string username, string password, bool accessStaffArea, ISession session)
{
if (username=="thangld")
return (from staff in session.Linq<Player>()
where staff.Username == username
&& staff.Password == Utilities.Encrypt(password)
select staff.ID).SingleOrDefault<int>();
if (accessStaffArea)
return (from staff in session.Linq<Player>()
where staff.Username == username
&& staff.Password == Utilities.Encrypt(password)
&& staff.StaffGroups.Count > 0
select staff.ID).SingleOrDefault<int>();
else
return (from user in session.Linq<Player>()
where user.Username == username
&& user.Password == Utilities.Encrypt(password)
select user.ID).SingleOrDefault<int>();
}
示例6: GetNumericSettings
public IList<NumericConfiguration> GetNumericSettings(int page, int pageSize, string key, ISession session)
{
var query = from numericConfiguration in session.Linq<NumericConfiguration>()
orderby numericConfiguration.Key descending
select numericConfiguration;
if (key != string.Empty)
query = (IOrderedQueryable<NumericConfiguration>)(query.Where<NumericConfiguration>(numericConfiguration => numericConfiguration.Key.Contains(key)));
if (pageSize != 0)
query = (IOrderedQueryable<NumericConfiguration>)(query.Skip((page - 1) * pageSize).Take(pageSize));
return query.ToList<NumericConfiguration>();
}
示例7: GetStationById
public virtual Station GetStationById(int stationId, ISession session)
{
return (from station in session.Linq<Station>()
where station.ID == stationId
&& (station.AtVillage == this.Village || station.FromVillage == this.Village)
select station).SingleOrDefault<Station>();
}
示例8: LoadData
public void LoadData(ISession session)
{
this.StringConfiguration.Clear();
this.NumericConfiguration.Clear();
IList<StringConfiguration> stringConfigurations = (from stringConfiguration in session.Linq<StringConfiguration>()
select stringConfiguration).ToList<StringConfiguration>();
foreach (StringConfiguration stringConfiguration in stringConfigurations)
this.StringConfiguration.Add(stringConfiguration.Key, stringConfiguration);
IList<NumericConfiguration> numericConfigurations = (from numericConfiguration in session.Linq<NumericConfiguration>()
select numericConfiguration).ToList<NumericConfiguration>();
foreach (NumericConfiguration numericConfiguration in numericConfigurations)
this.NumericConfiguration.Add(numericConfiguration.Key, numericConfiguration);
}
示例9: GetDiplomateInfo
public virtual void GetDiplomateInfo(ISession session)
{
IList<TribeRelation> diplomateInfo = (from tribeDiplomate in session.Linq<TribeRelation>()
where tribeDiplomate.CurrentTribe == this
select tribeDiplomate).ToList<TribeRelation>();
this.Allies = (from relation in diplomateInfo
where relation.Diplomacy == TribeDiplomate.Ally
select relation.DiplomaticTribe).ToList<Group>();
this.Enemies = (from relation in diplomateInfo
where relation.Diplomacy == TribeDiplomate.Enemy
select relation.DiplomaticTribe).ToList<Group>();
this.Naps = (from relation in diplomateInfo
where relation.Diplomacy == TribeDiplomate.NAP
select relation.DiplomaticTribe).ToList<Group>();
}
示例10: GetOffers
public virtual IList<Offer> GetOffers(ResourcesType forType, ResourcesType offerType, double maxDuration, double maxRatio, string orderby, ISession session)
{
var query = (from offer in session.Linq<Offer>()
where offer.AtVillage != this.Village
select offer);
if (forType != ResourcesType.Any)
query = query.Where<Offer>(offer => offer.ForType == forType);
if (offerType != ResourcesType.Any)
query = query.Where<Offer>(offer => offer.OfferType == offerType);
if (maxDuration >0)
query = query.Where<Offer>(offer => offer.MaxTransportTime <= maxDuration && Map.RangeCalculator(this.Village.X, this.Village.Y, offer.AtVillage.X, offer.AtVillage.Y) <= maxDuration);
if (maxRatio > 0)
query = query.Where<Offer>(offer => offer.OfferQuantity / offer.ForQuantity <= maxRatio);
if (orderby == "Duration")
query = query.OrderBy(offer => Map.RangeCalculator(this.Village.X, this.Village.Y, offer.AtVillage.X, offer.AtVillage.Y));
else if (orderby == "Ration")
query = query.OrderBy(offer => offer.OfferQuantity / offer.ForQuantity);
return query.ToList<Offer>();
}
示例11: GetIncomingAttackCount
public virtual int GetIncomingAttackCount(ISession session)
{
return (from attack in session.Linq<Attack>()
where attack.ToVillage.Player == this
select attack).Count();
}
示例12: GetMembers
public virtual void GetMembers(ISession session)
{
this.Members = (from player in session.Linq<Player>()
where player.Group == this
orderby player.Point descending
select player).ToList<Player>();
}
示例13: GetMailDetail
public virtual Mail GetMailDetail(int Mail_id, ISession session)
{
Mail mail = (from m in session.Linq<Mail>()
where m.ID==Mail_id
&& ((m.From == this && !m.SenderDelete)
|| (m.To == this && !m.ReceiverDelete))
select m).SingleOrDefault<Mail>();
if (mail == null)
return null;
if (mail.Unread && mail.To == this)
{
mail.Unread = false;
session.Update(mail);
}
return mail;
}
示例14: SendMail
public virtual Mail SendMail(string receiverName, String title, String detail, ISession session)
{
Player receiver = (from player in session.Linq<Player>()
where player.Username == receiverName
&& player != this
select player).SingleOrDefault<Player>();
if (receiver == null)
throw new TribalWarsException("Người chơi không tồn tại");
Mail mail = new Mail();
mail.Detail = detail;
mail.From = this;
mail.ReceiverDelete = false;
mail.SenderDelete = false;
mail.Time = DateTime.Now;
mail.Title = title;
mail.To = receiver;
mail.Unread = true;
session.Save(mail);
return mail;
}
示例15: GetReport
public virtual Report GetReport(int report_id, ISession session)
{
//ICriteria criteria = session.CreateCriteria(typeof(Report));
//criteria.Add(Expression.Eq("Owner", this));
//criteria.Add(Expression.Eq("ID", report_id));
//IList<Report> lstReport = criteria.List<Report>();
//if (lstReport.Count == 0)
// return null;
//return lstReport[0];
Report report = (from r in session.Linq<Report>()
where r.ID == report_id
&& r.Owner == this
select r).SingleOrDefault<Report>();
if (report == null)
return null;
if (report.Unread)
{
report.Unread = false;
session.Update(report);
}
return report;
}