Back to Devexpress

Entity Framework

windowsforms-118687-controls-and-libraries-scheduler-data-binding-data-sources-entity-framework.md

latest2.6 KB
Original Source

Entity Framework

  • Oct 29, 2020

  • 2 minutes to read

  • C#

  • VB.NET

csharp
public class DoctorAppointment {
        [Key]
        public Int64 Id { get; set; }
        public bool AllDay { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string PatientName { get; set; }
        public string Note { get; set; }
        public int PaymentStatusId { get; set; }
        public int IssueId { get; set; }
        public int EventType { get; set; }
        public string Location { get; set; }
        public string RecurrenceInfo { get; set; }
        public string ReminderInfo { get; set; }
        public Int64? DoctorId { get; set; }
    }
    public class Doctor {
        [Key]
        public Int64 Id { get; set; }
        public string Name { get; set; }
    }

    public class DoctorScheduleContext : DbContext {
        public DoctorScheduleContext()
            : base("name=DevExpress.XtraScheduler.Demos.Properties.Settings.DoctorConnectionString") {

        }
        public DbSet<DoctorAppointment> DoctorAppointments { get; set; }
        public DbSet<Doctor> Doctors { get; set; }
    }
vb
Public Class DoctorAppointment
        <Key> _
        Public Property Id() As Int64
        Public Property AllDay() As Boolean
        Public Property StartDate() As DateTime
        Public Property EndDate() As DateTime
        Public Property PatientName() As String
        Public Property Note() As String
        Public Property PaymentStatusId() As Integer
        Public Property IssueId() As Integer
        Public Property EventType() As Integer
        Public Property Location() As String
        Public Property RecurrenceInfo() As String
        Public Property ReminderInfo() As String
        Private privateDoctorId? As Int64
        Public Property DoctorId() As Int64?
            Get
                Return privateDoctorId
            End Get
            Set(ByVal value? As Int64)
                privateDoctorId = value
            End Set
        End Property
    End Class
    Public Class Doctor
        <Key> _
        Public Property Id() As Int64
        Public Property Name() As String
    End Class

    Public Class DoctorScheduleContext
        Inherits DbContext
        Public Sub New()
            MyBase.New("name=DevExpress.XtraScheduler.Demos.Properties.Settings.DoctorConnectionString")

        End Sub
        Public Property DoctorAppointments() As DbSet(Of DoctorAppointment)
        Public Property Doctors() As DbSet(Of Doctor)
    End Class