Наследование: System.Data.Objects.DataClasses.EntityObject
Пример #1
0
 /// <summary>
 /// Create a new Event object.
 /// </summary>
 /// <param name="eventId">Initial value of the EventId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="eventDate">Initial value of the EventDate property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static Event CreateEvent(global::System.Int32 eventId, global::System.String name, global::System.DateTime eventDate, global::System.Boolean isDeleted)
 {
     Event @event = new Event();
     @event.EventId = eventId;
     @event.Name = name;
     @event.EventDate = eventDate;
     @event.IsDeleted = isDeleted;
     return @event;
 }
Пример #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Events EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEvents(Event @event)
 {
     base.AddObject("Events", @event);
 }
Пример #3
0
 /// <summary>
 /// Saves this event.
 /// </summary>
 /// <returns></returns>
 public bool Save()
 {
     if (EventDate < DateTime.Today.Date) throw new ArgumentException("Ugyldig dato for stevne");
     using (var context = new Entities())
     {
         var newEvent = new Event();
         newEvent.Name = Name;
         newEvent.EventDate = EventDate;
         try
         {
             context.Events.AddObject(newEvent);
             context.SaveChanges();
             EventId = newEvent.EventId;
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }