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


C# Dota2Entities.SaveChanges方法代码示例

本文整理汇总了C#中GLyra.Dota2.Repositories.Dota2Entities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Dota2Entities.SaveChanges方法的具体用法?C# Dota2Entities.SaveChanges怎么用?C# Dota2Entities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GLyra.Dota2.Repositories.Dota2Entities的用法示例。


在下文中一共展示了Dota2Entities.SaveChanges方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: insert

        public SkillAbilityTypes insert(int skillId, int abilityTypeId, out bool success)
        {
            skillAbilityType = new SkillAbilityTypes();

            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    skillAbilityType.SkillId = skillId;
                    skillAbilityType.AbilityTypeId = abilityTypeId;

                    ctx.SkillAbilityTypes.Add(skillAbilityType);

                    ctx.SaveChanges();
                    success = true;
                }
                catch (Exception e)
                {
                    success = false;
                    throw e;
                }
            }            

            return skillAbilityType;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:25,代码来源:1392142967$SkillAbilityTypeCreator.cs

示例2: insertSkillEffectName

        public SkillEffectName insertSkillEffectName(string name, string heroName, string skillName, 
            List<string> skillEffectValues, string skillDescription)
        {
            SkillEffectName skillEffectName = new SkillEffectName();

            Skill skill = SkillCreator.SelectByName(skillName);

            skillEffectName.Name = name.Trim();

            

            skillEffectName = checkIfSkillNameExists(name, skill, skillDescription);

            if (skillEffectName == null)
            {
                using (Dota2Entities ctx = new Dota2Entities())
                {
                    try
                    {
                        skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
                        ctx.SaveChanges();
                        Console.WriteLine("Skill " + name + " Created");
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
            return skillEffectName;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:31,代码来源:1392758075$SkillEffectNameCreator.cs

示例3: InsertSkillEffectName

        public SkillEffectName InsertSkillEffectName(string name, string heroName, Skill skill, List<string> skillEffectValues)
        {
            SkillEffectName skillEffectName;            

            Skill completeSkill = SkillCreator.SelectByName(skill.Name);            

            bool exists = checkIfSkillNameExists(name, completeSkill, completeSkill.Description, out skillEffectName);

            if (!exists)
            {
                skillEffectName.Name = name.Trim();
                skillEffectName.SkillId = completeSkill.ID;
                skillEffectName.ValueLv1 = int.Parse(skillEffectValues.First());
                skillEffectName.ValueLv2 = int.Parse(skillEffectValues.ElementAt(1));
                skillEffectName.ValueLv3 = int.Parse(skillEffectValues.ElementAt(2));
                skillEffectName.ValueLv4 = int.Parse(skillEffectValues.ElementAt(3));
                skillEffectName.ValueScepter = int.Parse(skillEffectValues.Last());            

                using (Dota2Entities ctx = new Dota2Entities())
                {
                    try
                    {
                        skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
                        ctx.SaveChanges();
                        Console.WriteLine("Skill " + name + " Created");
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
            return skillEffectName;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:34,代码来源:1392929019$SkillEffectNameCreator.cs

示例4: InsertSkillImage

        public SkillImage InsertSkillImage(int skillId, string imageUrl)
        {
            SkillImage skillImage = new SkillImage();

            try
            {
                using (Dota2Entities ctx = new Dota2Entities())
                {
                    //Check if the image exists
                    if (!ctx.SkillImage.Any(si => si.Url == imageUrl))
                    {
                        skillImage.SkillId = skillId;
                        skillImage.Url = imageUrl;

                        ctx.SkillImage.Add(skillImage);
                        ctx.SaveChanges();
                    }
                    else
                    {
                        skillImage = ctx.SkillImage.Where(si => si.Url == imageUrl).FirstOrDefault();
                        Console.WriteLine("SkillImage Already exists");                        
                    }
                }
            }
            catch (Exception)
            {
                //TODO implementar log
                throw;
            }

            return skillImage;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:32,代码来源:1393450980$SkillImageCreator.cs

示例5: AttributesCreator

        public AttributesCreator(int heroId, Dictionary<string, string> primaryStats)
        {
            attribute = new Attributes();
            attribute.HeroId = heroId;
            attribute.Intelligence = primaryStats["Intelligence"];
            attribute.Agility = primaryStats["Agility"];
            attribute.Strength = primaryStats["Strength"];
            attribute.Damage = primaryStats["Damage"];
            attribute.MoveSpeed = primaryStats["Movespeed"];
            attribute.Armor = primaryStats["Armor"];

            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    ctx.Attributes.Add(this.attribute);

                    ctx.SaveChanges();
                    Console.WriteLine("Primary Stats Created ");
                }
                catch (Exception e)
                {
                    //TODO Adicionar ao log
                    throw e;
                }
            }
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:27,代码来源:AttributesCreator.cs

示例6: createHero

        public Hero createHero(string heroName, string biography)
        {
            this.hero = new Hero();

            this.hero.Name = heroName;
            this.hero.Biography = biography;

            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    ctx.Hero.Add(this.hero);

                    ctx.SaveChanges();
                    Console.WriteLine("*************************** " + heroName + " Created(Hero)" + "***************************");
                }
                catch (Exception e)
                {
                    //TODO Adicionar ao log
                    throw e;
                }
            }

            return this.hero;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:25,代码来源:1393440368$HeroCreator.cs

示例7: InsertHeroPortrait

        public HeroPortrait InsertHeroPortrait(int heroId, string imageUrl)
        {
            HeroPortrait HeroPortrait = new HeroPortrait();

            try
            {
                using (Dota2Entities ctx = new Dota2Entities())
                {
                    //Check if the image exists
                    if (!ctx.HeroPortrait.Any(si => si.Url == imageUrl))
                    {
                        HeroPortrait.HeroId = heroId;
                        HeroPortrait.Url = imageUrl;

                        ctx.HeroPortrait.Add(HeroPortrait);
                        ctx.SaveChanges();
                        Console.WriteLine("Image " + HeroPortrait.Url + " Added");
                    }
                    else
                    {
                        HeroPortrait = ctx.HeroPortrait.Where(si => si.Url == imageUrl).FirstOrDefault();
                        Console.WriteLine("HeroPortrait Already exists");
                    }
                }
            }
            catch (Exception)
            {
                //TODO implementar log
                throw;
            }

            return HeroPortrait;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:33,代码来源:HeroPortraitCreator.cs

示例8: createHero

        public Hero createHero(string name, List<string> primaryStats, string biography)
        {
            this.hero = new Hero();

            this.hero.Name = name;
            this.hero.Biography = biography;

            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                { 
                    ctx.Hero.Add(this.hero);

                    ctx.SaveChanges();
                }
                catch(Exception e)
                {
                    //TODO Adicionar ao log
                    throw e.Message;
                }


            return this.hero;
        }
        
    }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:26,代码来源:1392058036$HeroCreator.cs

示例9: insertSkillEffectName

        public SkillEffectName insertSkillEffectName(string name)
        {
            SkillEffectName skillEffectName = new SkillEffectName();

            skillEffectName.Name = name.Trim();

            using(Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
                    ctx.SaveChanges();
                    Console.WriteLine("Skill " + name + " Created");
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return skillEffectName;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:22,代码来源:1392756210$SkillEffectNameCreator.cs

示例10: InsertSkill

		/// <summary>
		/// Insert a new Skill and SkillAbilityTypes
		/// </summary>        
		private Skill InsertSkill()
		{
			SkillAbilityTypesCreator skillAbilityTypesCreator = new SkillAbilityTypesCreator();
			bool isSkillAbilityTypeInserted = false;
			using (Dota2Entities ctx = new Dota2Entities())
			{
				try
				{
					ctx.Skill.Add(this.skill);
					ctx.SaveChanges();
					foreach (var abilityType in abilityTypeList)
					{
						skillAbilityTypesCreator.insert(this.skill.ID, abilityType.ID, out isSkillAbilityTypeInserted);
						//If we have a error when inserting SkillAbilityType, then delete the inserted skill
						if(!isSkillAbilityTypeInserted)
						{
							//TODO Create a function to remove all the SkillAbilityTypes that have been created for this skill
							ctx.Skill.Remove(this.skill);
						}
					}
					
					
				}
				catch (Exception e)
				{
					//TODO Adicionar ao log
					throw e;
				}
			}

			return this.skill;
		}
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:35,代码来源:SkillCreator.cs

示例11: insertSkill

        /// <summary>
        /// Insert a new Skill and SkillAbilityTypes
        /// </summary>        
        Skill insertSkill()
        {
            SkillAbilityTypesCreator skillAbilityTypesCreator = new SkillAbilityTypesCreator();
            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    ctx.Skill.Add(this.skill);
                    foreach (var abilityType in abilityTypeList)
	                {
		                skillAbilityTypesCreator.insert(this.skill.ID, abilityType.ID);
	                }
                    
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    //TODO Adicionar ao log
                    throw e;
                }
            }

            return this.skill;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:27,代码来源:1392134415$SkillCreator.cs

示例12: InsertSkillEffectName

        public SkillEffectName InsertSkillEffectName(string name, string heroName, Skill skill, List<string> skillEffectValues)
        {
            HeroCreator heroCreator = new HeroCreator();
            SkillEffectName skillEffectName;
            Hero hero = heroCreator.getHeroByName(heroName);

            Skill completeSkill = SkillCreator.SelectSkill(skill.Name, hero.ID);            

            bool exists = checkIfSkillNameExists(name, completeSkill, completeSkill.Description, out skillEffectName);

            if (!exists)
            {
                skillEffectName.Name = name.Trim();
                skillEffectName.SkillId = completeSkill.ID;
                if (skillEffectValues.FirstOrDefault() != null)
                    skillEffectName.ValueLv1 = skillEffectValues.First();
                if (skillEffectValues.ElementAtOrDefault(1) != null)
                    skillEffectName.ValueLv2 = skillEffectValues.ElementAt(1);
                if (skillEffectValues.ElementAtOrDefault(2) != null)
                    skillEffectName.ValueLv3 = skillEffectValues.ElementAt(2);
                if (skillEffectValues.ElementAtOrDefault(3) != null)
                    skillEffectName.ValueLv4 = skillEffectValues. ElementAt(3);
                if (skillEffectValues.LastOrDefault() != null)
                    skillEffectName.ValueScepter = skillEffectValues.Last();            

                using (Dota2Entities ctx = new Dota2Entities())
                {
                    try
                    {
                        skillEffectName = ctx.SkillEffectName.Add(skillEffectName);
                        ctx.SaveChanges();
                        Console.WriteLine("Skill " + name + " Created");
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
            return skillEffectName;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:41,代码来源:SkillEffectNameCreator.cs

示例13: insertSkill

        Skill insertSkill()
        {
            using (Dota2Entities ctx = new Dota2Entities())
            {
                try
                {
                    ctx.Skill.Add(this.skill);

                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    //TODO Adicionar ao log
                    throw e;
                }
            }

            return this.skill;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:19,代码来源:1392133452$SkillCreator.cs


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