public int SaveMessage(int fromPersonId, string subject, string body, string messageType) { var message = new Message { Body = body, Subject = subject, MessageFrom = fromPersonId, MessageType = messageType }; Context.AddToMessages(message); Context.SaveChanges(); return message.MessageId; }
/// <summary> /// Create a new Message object. /// </summary> /// <param name="messageId">Initial value of the MessageId property.</param> /// <param name="messageFrom">Initial value of the MessageFrom property.</param> /// <param name="messageType">Initial value of the MessageType property.</param> public static Message CreateMessage(global::System.Int32 messageId, global::System.Int32 messageFrom, global::System.String messageType) { Message message = new Message(); message.MessageId = messageId; message.MessageFrom = messageFrom; message.MessageType = messageType; return message; }
/// <summary> /// Deprecated Method for adding a new object to the Messages EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMessages(Message message) { base.AddObject("Messages", message); }