public int AddCarType(string carTypeName) { try { CarType type = new CarType(); type.TypeName = carTypeName; context.AddToCarType(type); context.SaveChanges(); return 1; } catch (Exception) { return 0; } }
/// <summary> /// 创建新的 CarType 对象。 /// </summary> /// <param name="id">ID 属性的初始值。</param> /// <param name="typeName">TypeName 属性的初始值。</param> public static CarType CreateCarType(global::System.Int32 id, global::System.String typeName) { CarType carType = new CarType(); carType.ID = id; carType.TypeName = typeName; return carType; }
/// <summary> /// 用于向 CarType EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToCarType(CarType carType) { base.AddObject("CarType", carType); }