Base solution for your next web application

Activities of "tiandao"

beause the second dbcontext constructor ,delete this code

"public HisDbContext(string nameOrConnectionString) : base(nameOrConnectionString) { } public HisDbContext(DbConnection connection) : base(connection, true) { } "

I tried disable uow and use custom repository ,but my application throw exception ,not work correctly . this time ,I use sqlserver database and other database . 1.custom repository interface :

public interface IPacsRepository:IRepository<Register>
    {
    List<string> Patientinfo();
    }

2.implement :

public class PacsRepository : PacsRepositoryBase<Register>,IPacsRepository
    {
      
        public PacsRepository(IDbContextProvider<PacsDbContext> dbContextProvider) : base(dbContextProvider)
        {


        }

        public List<string> Patientinfo()
        {

            var query = GetAllList().Select(p => p.BrName).ToList();
            return query;
        }
    }

3.called in service :

public class PacsAppService : ApplicationService,IPacsAppService
    {

        
        private readonly IPacsRepository _ppacsRepository; //custom repository 
        public PacsAppService(IPacsRepository ppacsRepository)
        {
            _ppacsRepository = ppacsRepository; //custom repository 

        }


        [UnitOfWork(IsDisabled=true)]
        public List<string> Patientinfo()
        {
            var register = _ppacsRepository.Patientinfo();
            return register;

        }
    }

My application have two database . the one is sql and another one is oracle so .I add the second dbcontext ,in my application ,I want to use procedure or sqlcommand.I saw issue <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/574">https://github.com/aspnetboilerplate/as ... issues/574</a> <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/583">https://github.com/aspnetboilerplate/as ... issues/583</a> follow this : 1.I generate code from website ,and use module zero template . so ,the first main dbcontext is "webapidbcontext ". 2. install Oracle Data Provider for .NET (ODP.NET) Managed Driver, run the following command in the Package Manager Console:Install-Package odp.net.managed. config connectstring like this

<add name="Default" connectionString="Server=localhost; Database=WebApi; Trusted_Connection=True;" providerName="System.Data.SqlClient" />
  <add name="His" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=QXYY;Password=qxyy;Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = TianDao-Pc)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = QXHIS) ))" />
  1. Then added second dbcontext :
public class HisDbContext: AbpDbContext
    {

       //patient entity
        public virtual DbSet<PATIENT> PATIENT { get; set; }
    
        public HisDbContext()
            : base("His")
        {
            
        }

        public HisDbContext(string nameOrConnectionString)
            : base(nameOrConnectionString)
        {

        }

        public HisDbContext(DbConnection connection)
            : base(connection, true)
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
          base.OnModelCreating(modelBuilder);
          modelBuilder.HasDefaultSchema("QXYY");
          modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
          modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
          modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }

4.add patient entity : public class PATIENT:Entity<int> { public long PID { get; set; } public string NAME { get; set; } } 5.modify module:

public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            Database.SetInitializer<WebApiDbContext>(null);
            Database.SetInitializer<HisDbContext>(null);
        }

6.migration and updatebase: Enable-Migrations -MigrationsDirectory "MigrationsHis" -ContextTypeName "HisDbContext" Add-Migration -configuration TianDao.WebApi.MigrationsHis.Configuration inital Update-Database -ConfigurationTypeName "TianDao.WebApi.MigrationsHis.Configuration" 7.add service interface : public interface IHisAppService : IApplicationService { [HttpGet] List<PatientDto> AllPatientinfo(); } 8.implement service interface: public class HisAppService : ApplicationService, IHisAppService { private readonly IRepository<PATIENT> _patientRepository; public HisAppService(IRepository<PATIENT> patientRepository) { _patientRepository = patientRepository; }

    public List&lt;PatientDto&gt; AllPatientinfo()
    {
            var p = _patientRepository.GetAllList();
            var p2 = p.MapTo&lt;List&lt;PatientDto&gt;>();
            return p2;
     }
}

9.finaly,after login ,I access this URL:http://localhost:6234/api/services/webapi/his/AllPatientinfo from browser. but throw Exception.I saw log ,find this :System.Data.SqlClient.SqlException: object name 'QXYY.PATIENT' is invalid .I find this is a uow exception ,in HisAppService allpatientinfo method current dbcontext is webapicontext ,not hisdbcontext . why? i think this error should not Happen.

can you give me solution? thank you . i want use procedure(hisdbcontext) in my application ,can you give me solution? thank you .thank you.thank you

very very good~thanks hikalkan!

oh,some China network not upload picture to github, i will write a email to you for later.

Wish you happiness

Thanks for your reply

Hi hikalkan ; I have a problem in abp zero,for example; I reference script in ui page,like this picture: [attachment=2:2jhwy86w]1.png[/attachment:2jhwy86w] Next, JS proxy debug results like this: [attachment=1:2jhwy86w]2.png[/attachment:2jhwy86w] But, when i Debugger in ui page, allPermissions result is null. Why?can you help me .thank you .[attachment=0:2jhwy86w]3.png[/attachment:2jhwy86w]

thank you

Showing 1 to 6 of 6 entries