当前位置: 首页>>代码示例>>C#>>正文


C# ISession.Linq方法代码示例

本文整理汇总了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);
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:29,代码来源:Player.Methods.Tribe.cs

示例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>();
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:8,代码来源:StaffManagementService.cs

示例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>();
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:9,代码来源:Administrator.Methods.Authentication.cs

示例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);
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:12,代码来源:StaffManagementService.cs

示例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>();
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:21,代码来源:SecurityService.cs

示例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>();
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:15,代码来源:AdminConfigurationMethods.cs

示例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>();
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:7,代码来源:VillageTroopMethods.cs

示例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);
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:16,代码来源:Configuration.cs

示例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>();

        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:17,代码来源:Group.cs

示例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>();
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:22,代码来源:VillageMarketMethods.cs

示例11: GetIncomingAttackCount

 public virtual int GetIncomingAttackCount(ISession session)
 {
     return (from attack in session.Linq<Attack>()
             where attack.ToVillage.Player == this
             select attack).Count();
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:6,代码来源:Player.cs

示例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>();
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:7,代码来源:Group.cs

示例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;

        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:20,代码来源:Player.cs

示例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;
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:24,代码来源:Player.cs

示例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;
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:22,代码来源:Player.cs


注:本文中的ISession.Linq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。