1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5: using Microsoft.EntityFrameworkCore;
6: using System.ComponentModel.DataAnnotations;
7: using System.Xml.Linq;
8: using System.Configuration;
9:
10: namespace Ia.Islamic.Cl.Model.Context
11: {
12: ////////////////////////////////////////////////////////////////////////////
13:
14: /// <summary publish="true">
15: /// Koran Reference Network Data Context
16: /// </summary>
17: /// <value>
18: /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
19: /// </value>
20: /// <remarks>
21: /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
22: ///
23: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
24: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
25: ///
26: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
27: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
28: ///
29: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
30: ///
31: /// Copyright notice: This notice may not be removed or altered from any source distribution.
32: /// </remarks>
33: public class Koran : DbContext
34: {
35: ////////////////////////////////////////////////////////////////////////////
36:
37: /// <summary>
38: ///
39: /// </summary>
40: public Koran() { }
41:
42: ////////////////////////////////////////////////////////////////////////////
43:
44: /// <summary>
45: ///
46: /// </summary>
47: public Koran(DbContextOptions<DbContext> options) : base(options) { }
48:
49: ////////////////////////////////////////////////////////////////////////////
50:
51: /// <summary>
52: ///
53: /// </summary>
54: protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
55: {
56: optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
57: }
58:
59: ////////////////////////////////////////////////////////////////////////////
60:
61: /// <summary>
62: ///
63: /// </summary>
64: protected override void OnModelCreating(ModelBuilder modelBuilder)
65: {
66: modelBuilder.Entity<WordVerse>().HasKey(bc => new { bc.VerseId, bc.WordId });
67:
68: modelBuilder.Entity<WordVerse>().HasOne(bc => bc.Verse).WithMany(b => b.WordVerses).HasForeignKey(bc => bc.VerseId);
69:
70: modelBuilder.Entity<WordVerse>().HasOne(bc => bc.Word).WithMany(c => c.WordVerses).HasForeignKey(bc => bc.WordId);
71: }
72:
73: /// <summary/>
74: public DbSet<Ia.Islamic.Cl.Model.Koran> Korans { get; set; }
75:
76: /// <summary/>
77: public DbSet<Chapter> Chapters { get; set; }
78:
79: /// <summary/>
80: public DbSet<Verse> Verses { get; set; }
81:
82: /// <summary/>
83: public DbSet<Word> Words { get; set; }
84:
85: /// <summary/>
86: public DbSet<WordVerse> WordVerses { get; set; }
87:
88: /// <summary/>
89: public DbSet<VerseTopic> VerseTopics { get; set; }
90:
91: ////////////////////////////////////////////////////////////////////////////
92: ////////////////////////////////////////////////////////////////////////////
93: }
94: }