)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » KoranDbContext (Ia.Islamic.Cl)

Public general use code classes and xml files that we've compiled and used over the years:

Koran Reference Network Data Context

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