wrong way to multi multi db

This commit is contained in:
Arti Zirk 2017-03-08 14:38:36 +02:00
parent 74a391db4f
commit 9ede003205
6 changed files with 84 additions and 0 deletions

22
Domain/Cource.cs Normal file
View 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>();
}
}

View File

@ -41,8 +41,12 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Cource.cs" />
<Compile Include="Enums\PersonType.cs" />
<Compile Include="Person.cs" /> <Compile Include="Person.cs" />
<Compile Include="PersonCources.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Subject.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View 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
}
}
}

View File

@ -20,6 +20,8 @@ namespace Domain
[Required] [Required]
public string LastName { get; set; } public string LastName { get; set; }
public virtual List<Cource> Courses { get; set; }
#region NotMaped #region NotMaped
public string FirstLastName => $"{FirstName} {LastName}"; public string FirstLastName => $"{FirstName} {LastName}";
public string LastFirstName => $"{LastName} {FirstName}"; public string LastFirstName => $"{LastName} {FirstName}";

19
Domain/PersonCources.cs Normal file
View 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
View 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>();
}
}