(MVC) MVC (2018)

<<назад Student.vb (Contoso University).

   1:  'Const Type = "Intro"
   2:  '#Const Type = "DataType1"
   3:  '#Const Type = "StringLength"
   4:  '#Const Type = "Column"
   5:  '#Const Type = "BeforeInheritance"
   6:  #Const Type = "AfterInheritance"
   7:   
   8:   
   9:  #If Type = "Intro" Then
  10:   
  11:  Imports System
  12:  Imports System.Collections.Generic
  13:   
  14:  Namespace Models
  15:   
  16:      Public Class Student
  17:   
  18:          Public Property ID As Integer
  19:   
  20:          Public Property LastName As String
  21:   
  22:          Public Property FirstMidName As String
  23:   
  24:          Public Property EnrollmentDate As DateTime
  25:   
  26:          Public Property Enrollments As ICollection(Of Enrollment)
  27:      End Class
  28:  End Namespace
  29:   
  30:  #ElseIf Type = "DataType1" Then
  31:   
  32:  Imports System
  33:  Imports System.Collections.Generic
  34:  Imports System.ComponentModel.DataAnnotations
  35:   
  36:  Namespace Models
  37:   
  38:      Public Class Student
  39:   
  40:          Public Property ID As Integer
  41:   
  42:          Public Property LastName As String
  43:   
  44:          Public Property FirstMidName As String
  45:   
  46:          <DataType(DataType.Date)>
  47:          <DisplayFormat(DataFormatString:="{0:yyyy-MM-dd}", ApplyFormatInEditMode:=True)>
  48:          Public Property EnrollmentDate As DateTime
  49:   
  50:          Public Property Enrollments As ICollection(Of Enrollment)
  51:      End Class
  52:  End Namespace
  53:   
  54:  #ElseIf Type = "StringLength" Then
  55:   
  56:   
  57:  Imports System
  58:  Imports System.Collections.Generic
  59:  Imports System.ComponentModel.DataAnnotations
  60:   
  61:  Namespace Models
  62:   
  63:      Public Class Student
  64:   
  65:          Public Property ID As Integer
  66:   
  67:          <StringLength(50)>
  68:          Public Property LastName As String
  69:   
  70:          <StringLength(50, ErrorMessage:="First name cannot be longer than 50 characters.")>
  71:          Public Property FirstMidName As String
  72:   
  73:          <DataType(DataType.Date)>
  74:          <DisplayFormat(DataFormatString:="{0:yyyy-MM-dd}", ApplyFormatInEditMode:=True)>
  75:          Public Property EnrollmentDate As DateTime
  76:   
  77:          Public Property Enrollments As ICollection(Of Enrollment)
  78:      End Class
  79:  End Namespace
  80:   
  81:  #ElseIf Type = "Column" Then
  82:   
  83:  Imports System
  84:  Imports System.Collections.Generic
  85:  Imports System.ComponentModel.DataAnnotations
  86:  Imports System.ComponentModel.DataAnnotations.Schema
  87:   
  88:  Namespace Models
  89:   
  90:      Public Class Student
  91:   
  92:          Public Property ID As Integer
  93:   
  94:          <StringLength(50)>
  95:          Public Property LastName As String
  96:   
  97:          <StringLength(50, ErrorMessage:="First name cannot be longer than 50 characters.")>
  98:          <Column("FirstName")>
  99:          Public Property FirstMidName As String
 100:   
 101:          <DataType(DataType.Date)>
 102:          <DisplayFormat(DataFormatString:="{0:yyyy-MM-dd}", ApplyFormatInEditMode:=True)>
 103:          Public Property EnrollmentDate As DateTime
 104:   
 105:          Public Property Enrollments As ICollection(Of Enrollment)
 106:      End Class
 107:  End Namespace
 108:   
 109:   
 110:  #ElseIf Type = "BeforeInheritance" Then
 111:   
 112:  Imports System
 113:  Imports System.Collections.Generic
 114:  Imports System.ComponentModel.DataAnnotations
 115:  Imports System.ComponentModel.DataAnnotations.Schema
 116:   
 117:  Namespace Models
 118:   
 119:      Public Class Student
 120:   
 121:          Public Property ID As Integer
 122:   
 123:          <Required>
 124:          <StringLength(50)>
 125:          <Display(Name:="Last Name")>
 126:          Public Property LastName As String
 127:   
 128:          <Required>
 129:          <StringLength(50, ErrorMessage:="First name cannot be longer than 50 characters.")>
 130:          <Column("FirstName")>
 131:          <Display(Name:="First Name")>
 132:          Public Property FirstMidName As String
 133:   
 134:          <DataType(DataType.Date)>
 135:          <DisplayFormat(DataFormatString:="{0:yyyy-MM-dd}", ApplyFormatInEditMode:=True)>
 136:          <Display(Name:="Enrollment Date")>
 137:          Public Property EnrollmentDate As DateTime
 138:   
 139:          <Display(Name:="Full Name")>
 140:          Public ReadOnly Property FullName As String
 141:              Get
 142:                  Return LastName & ", " & FirstMidName
 143:              End Get
 144:          End Property
 145:   
 146:          Public Property Enrollments As ICollection(Of Enrollment)
 147:      End Class
 148:  End Namespace
 149:   
 150:  #ElseIf Type = "AfterInheritance" Then
 151:   
 152:  Imports System
 153:  Imports System.Collections.Generic
 154:  Imports System.ComponentModel.DataAnnotations
 155:  Imports System.ComponentModel.DataAnnotations.Schema
 156:   
 157:  Namespace Models
 158:   
 159:      Public Class Student
 160:          Inherits Person
 161:   
 162:          <DataType(DataType.Date)>
 163:          <DisplayFormat(DataFormatString:="{0:yyyy-MM-dd}", ApplyFormatInEditMode:=True)>
 164:          <Display(Name:="Enrollment Date")>
 165:          Public Property EnrollmentDate As DateTime
 166:   
 167:          Public Property Enrollments As ICollection(Of Enrollment)
 168:      End Class
 169:  End Namespace
 170:   
 171:  #End If
 172:   


Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/EF-missing-FAQ/Code/Student.vb.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>