-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestModelContext.cs
77 lines (57 loc) · 2.32 KB
/
TestModelContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace App
{
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Validation;
using System.Linq;
using System.Text;
using WinForm.Entities.Application;
using WinForm.Entities.Authentication;
using WinForm.Entities.ContactInformations;
using WinForm.Entities.Security;
public class TestModelContext : DbContext
{
public TestModelContext() : base(@"data source =.\SQLEXPRESS; initial catalog = generic_winapp_test; user = sa; password = admintp4; MultipleActiveResultSets = True; App = EntityFramework")
{
}
public TestModelContext(string connectionString):base(connectionString)
{
}
//
// WinForm : Authentication
//
public virtual DbSet<Role> Roles { get; set; }
public virtual DbSet<User> Users { get; set; }
//
// WinFrom : Application
//
public virtual DbSet<MenuItemApplication> MenuItemApplications { get; set; }
//
// WinForm : ContactInformationss
//
public virtual DbSet<Country> Countrys { get; set; }
public virtual DbSet<City> Citys { get; set; }
public virtual DbSet<ContactInformation> ContactInformations { get; set; }
////
//// Project management system
////
//public virtual DbSet<Project> Projets { get; set; }
//public virtual DbSet<ProjectTask> Taches { get; set; }
//public virtual DbSet<ProjectCategory> ProjectCategorys { get; set; }
//public virtual DbSet<RessouceProject> RessouceProjects { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
/// <summary>
/// trouver la liste des type des objets dans le context
/// </summary>
/// <returns></returns>
public List<Type> GetTypesSets()
{
var sets = from p in typeof(TestModelContext).GetProperties() where p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(DbSet<>) let entityType = p.PropertyType.GetGenericArguments().First() select p.PropertyType.GetGenericArguments()[0];
return sets.ToList<Type>();
}
}
}