/// <summary> /// 用于向 FactionMsgs EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToFactionMsgs(FactionMsg factionMsg) { base.AddObject("FactionMsgs", factionMsg); }
/// <summary> /// 创建新的 FactionMsg 对象。 /// </summary> /// <param name="factionMsgID">FactionMsgID 属性的初始值。</param> /// <param name="factionID">FactionID 属性的初始值。</param> /// <param name="msg">Msg 属性的初始值。</param> /// <param name="createTime">CreateTime 属性的初始值。</param> public static FactionMsg CreateFactionMsg(global::System.Int32 factionMsgID, global::System.Int64 factionID, global::System.String msg, global::System.DateTime createTime) { FactionMsg factionMsg = new FactionMsg(); factionMsg.FactionMsgID = factionMsgID; factionMsg.FactionID = factionID; factionMsg.Msg = msg; factionMsg.CreateTime = createTime; return factionMsg; }
public void AddMsg(string msg, Faction fan) { using (LdxyDBEntities dbcontext = new LdxyDBEntities()) { FactionMsg msgobj = new FactionMsg { Msg = msg, FactionID = fan.FactionID, CreateTime = DateTime.Now }; dbcontext.FactionMsgs.AddObject(msgobj); dbcontext.SaveChanges(); } }