wrong way to multi multi db
This commit is contained in:
parent
74a391db4f
commit
9ede003205
22
Domain/Cource.cs
Normal file
22
Domain/Cource.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace Domain
|
||||
{
|
||||
public class Cource
|
||||
{
|
||||
public int CourceId { get; set; }
|
||||
|
||||
// if not required, use nullable int - int?. Dadabase pics it up
|
||||
// always specify foregin key manualy
|
||||
public int SubjectId { get; set; }
|
||||
public Subject Subject { get; set; }
|
||||
|
||||
public virtual List<Person> Persons { get; set; } = new List<Person>();
|
||||
}
|
||||
}
|
@ -41,8 +41,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cource.cs" />
|
||||
<Compile Include="Enums\PersonType.cs" />
|
||||
<Compile Include="Person.cs" />
|
||||
<Compile Include="PersonCources.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Subject.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
16
Domain/Enums/PersonType.cs
Normal file
16
Domain/Enums/PersonType.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Domain.Enums
|
||||
{
|
||||
class PersonType
|
||||
{
|
||||
public enum PersonTypeEnum {
|
||||
Student,
|
||||
Teacher
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@ namespace Domain
|
||||
[Required]
|
||||
public string LastName { get; set; }
|
||||
|
||||
public virtual List<Cource> Courses { get; set; }
|
||||
|
||||
#region NotMaped
|
||||
public string FirstLastName => $"{FirstName} {LastName}";
|
||||
public string LastFirstName => $"{LastName} {FirstName}";
|
||||
|
19
Domain/PersonCources.cs
Normal file
19
Domain/PersonCources.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Domain
|
||||
{
|
||||
public class PersonCources
|
||||
{
|
||||
public int PersonCourcesId { get; set; }
|
||||
|
||||
public int PersonId { get; set; }
|
||||
public Person Person { get; set; }
|
||||
|
||||
public int CourceId { get; set; }
|
||||
public Cource Cource { get; set; }
|
||||
}
|
||||
}
|
21
Domain/Subject.cs
Normal file
21
Domain/Subject.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace Domain
|
||||
{
|
||||
class Subject
|
||||
{
|
||||
public int SubjectId { get; set; }
|
||||
|
||||
[MaxLength(128)]
|
||||
public string SubjectName { get; set; }
|
||||
|
||||
// use virtual to allow entity framework lazy loading
|
||||
public virtual List<Cource> Cources { get; set; } = new List<Cource>();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user