/// <summary>
 /// 创建新的 Activity_City 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="cityId">CityId 属性的初始值。</param>
 /// <param name="activityId">ActivityId 属性的初始值。</param>
 /// <param name="cityName">CityName 属性的初始值。</param>
 public static Activity_City CreateActivity_City(global::System.Guid id, global::System.Int32 cityId, global::System.Guid activityId, global::System.String cityName)
 {
     Activity_City activity_City = new Activity_City();
     activity_City.Id = id;
     activity_City.CityId = cityId;
     activity_City.ActivityId = activityId;
     activity_City.CityName = cityName;
     return activity_City;
 }
Example #2
0
        public List<string> AddCityList(string id,List<int> cities)
        {
            Guid guid=new Guid(id);
            List<string> returnModel = new List<string>();
            foreach (int city in cities)
            {
                try
                {
                    Activity_City model = new Activity_City()
                    {
                        Id = Guid.NewGuid(),
                        CityId = city,
                        ActivityId = guid
                    };
                   
                    returnModel.Add(db.Cities.Where(c => c.CityId == city).First().Name);
                    db.AddToActivity_Citys(model);
                    
                }
                catch
                {
                    continue;
                }

            }
            db.SaveChanges();
            return returnModel;

        }
 /// <summary>
 /// 用于向 Activity_Citys EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToActivity_Citys(Activity_City activity_City)
 {
     base.AddObject("Activity_Citys", activity_City);
 }