using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Data;
|
using System.Data.Entity;
|
using PalGain.Core;
|
using PalGain.Core.Tasks;
|
using sbcLabSystem.Data.Domain.Account;
|
using sbcLabSystem.Data.Domain.Backstage;
|
|
namespace sbcLabSystem.Data.DBContext
|
{
|
public class FreseniusDBContext : DbContext, IDbContext
|
{
|
//public IDbSet<InterfaceInfo> InterfaceInfos { get; set; }
|
public IDbSet<UserInfo> UserInfos { get; set; }
|
public IDbSet<RoleInfo> RoleInfos { get; set; }
|
public IDbSet<ResourceInfo> ResourceInfos { get; set; }
|
public IDbSet<UserRequestInfo> UserRequestInfos { get; set; }
|
public IDbSet<Menus> MenusInfo { get; set; }
|
public IDbSet<EmileInfo> EmileInfo { get; set; }
|
public IDbSet<QCDistribution> QCDistribution { get; set; }
|
public IDbSet<QCDistributionRegisterInfo> QCDistributionRegister { get; set; }
|
public IDbSet<ScheduleTask> ScheduleTaskes { get; set; }
|
public IDbSet<EmailSmtpInfo> EmailSmtpInfos { get; set; }
|
public IDbSet<StandAnswerInfo> StandAnswerInfos { get; set; }
|
public IDbSet<ApprovalInfo> ApprovalInfos { get; set; }
|
public IDbSet<Resultspercentage> Resultspercentage { get; set; }
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
{
|
modelBuilder.Entity<QCDistribution>()
|
.HasMany(p => p.QCDistributionRegisters).WithRequired(p => p.QCDistributionInfo)
|
.HasForeignKey(p => p.QCDistributionId).WillCascadeOnDelete(false);
|
modelBuilder.Entity<QCDistributionRegisterInfo>()
|
.HasRequired(p => p.LabInfo).WithMany(p => p.QCDistributionRegisterInfos)
|
.HasForeignKey(p => p.LabId).WillCascadeOnDelete(false);
|
modelBuilder.Entity<QCDistribution>()
|
.HasOptional(p => p.StandAnswer).WithRequired(p => p.QCDistInfo)
|
.Map(p => p.MapKey("QCDistInfoId"))
|
.WillCascadeOnDelete(true);
|
base.OnModelCreating(modelBuilder);
|
}
|
|
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
|
{
|
return base.Set<TEntity>();
|
}
|
|
public IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new()
|
{
|
throw new NotImplementedException();
|
}
|
|
public IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters)
|
{
|
return this.Database.SqlQuery<TElement>(sql, parameters);
|
}
|
|
public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters)
|
{
|
int? previousTimeout = null;
|
//if (timeout.HasValue)
|
//{
|
// //store previous timeout
|
// previousTimeout = ((IObjectContextAdapter)this).ObjectContext.CommandTimeout;
|
// ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = timeout;
|
//}
|
|
var transactionalBehavior = doNotEnsureTransaction
|
? TransactionalBehavior.DoNotEnsureTransaction
|
: TransactionalBehavior.EnsureTransaction;
|
var result = this.Database.ExecuteSqlCommand(transactionalBehavior, sql, parameters);
|
|
//if (timeout.HasValue)
|
//{
|
// //Set previous timeout back
|
// ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = previousTimeout;
|
//}
|
|
//return result
|
return result;
|
}
|
|
public void Detach(object entity)
|
{
|
throw new NotImplementedException();
|
}
|
|
public bool ProxyCreationEnabled
|
{
|
get
|
{
|
throw new NotImplementedException();
|
}
|
set
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public bool AutoDetectChangesEnabled
|
{
|
get
|
{
|
throw new NotImplementedException();
|
}
|
set
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|
}
|