Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "verrrrrrrrrrrrrdi"

Answer

<cite>alper: </cite> can you show what you did in SaveAsync method

public override Task SaveAsync(ExtendedAuditInfo auditInfo)
       {      
      ---> do your custom insert <--- 
       }
using System;
using System.Threading.Tasks;
using Abp.Auditing;
using Abp.Domain.Repositories;

namespace CompanyName.ProjectName.Extended.Auditing
{
    public class ExtendedAuditStore : AuditingStore
    {
        public ExtendedAuditStore(IRepository<ExtendedAuditInfo , long> auditLogRepository) : base(auditLogRepository) //Error : cannot be used as type parameter ‘TEntity’ in the generic type or method ‘IRepository<TEntity, PrimaryKey>’. There is no implicit reference conversion from ‘ExtendedAuditInfo’ to ‘Abp.Domain.Entities.IEntity<long>’
        {
        }
    public override Task SaveAsync(ExtendedAuditInfo auditInfo) //Error : no suitable method found to override" because i using ExtendedAuditInfo as parameter in saveasync. 
        {
           var result = base.SaveAsync(auditInfo);
    
            return result;
        }   
    }
}
Answer

Hi @alper,

I got this error message when implementing your code

cannot be used as type parameter ‘TEntity’ in the generic type or method ‘IRepository<TEntity, PrimaryKey>’. There is no implicit reference conversion from ‘ExtendedAuditInfo’ to ‘Abp.Domain.Entities.IEntity<long>’

Answer

Hi @aaron ,

  1. Extend auditlog entity. add ApplicationName Property
  2. want to save auditlog to entity with applicationName value

Extend AuditingStore

using System;
using System.Threading.Tasks;
using Abp.Auditing;
using Abp.Domain.Repositories;

namespace CompanyName.ProjectName.Extended.Auditing
{
    public class ExtendedAuditStore : AuditingStore
    {
        public ExtendedAuditStore(IRepository<AuditLog, long> auditLogRepository) : base(auditLogRepository)
        {
        }

        public override Task SaveAsync(ExtendedAuditInfo auditInfo)
        {
            var result = base.SaveAsync(auditInfo);

            return result;
        }   
    }
}

Extend AuditInfo

using System;
using Abp.Auditing;

namespace CompanyName.ProjectName.Extended.Auditing
{
    public class ExtendedAuditInfo : AuditInfo
    {
        public string ApplicationName { get; set; }
    }
}

Then i got error "no suitable method found to override" because i using ExtendedAuditInfo as parameter in saveasync. can you help me ?

this link is has a same case wih me: #143@9631572b-914f-48a0-b397-5fc4249f15fb

Answer

<cite>alper: </cite>

  • Extend AuditLog entity (inherit).
  • Replace IAuditingStore with your own implementation to save extended auditlog entity.

can you share a code snippet? i have problem when extending AuditInfo. Do you have sample code to save auditInfo to audit log with extending property ?

Answer

Hi @ismcagdas,

It solved. Thanks for your help

Answer

Hi @ismcagdas,

OK i wil take your solution using on premise server and enable MSDTC. I have enable MSDTC in my dedicated server but when i use both dbContext in same transaction it show error:

The specified transaction is not associated with the current connection. Only transactions associated with the current connection may be used.

If i add the constructor :

public DbContextB()
        : base("ConnStringB")
    {

    }
    
    public DbContextB(string nameOrConnectionString)
        : base(nameOrConnectionString)
    {

    }

    public DbContextB(DbConnection existingConnection)
        : base(existingConnection, false)
    {

    }

    public DbContextB(DbConnection existingConnection, bool contextOwnsConnection)
        : base(existingConnection, contextOwnsConnection)
    {

    }

it show error

Invalid Object Name dbo.TableB

because it always use "Default" connection string and TableB is belong to DatabaseB which use DbContextB. can you help me?

Answer

Hi @ismcagdas,

Yes i want to use both dbContext in same transaction (UOW). So you mean the way to solve this case is using MSDTC ?

Do you have sample implementation with multiple database using ASP.NET Core + Angular template? this sample <a class="postlink" href="https://github.com/aspnetboilerplate/as">https://github.com/aspnetboilerplate/as</a> ... ontextDemo is for ASP.NET MVC 5 + Angular js 1.x

Answer

hi @ismcagdas,

Yes, i have try it. I has implemented new EF Transaction Strategy using this link: <a class="postlink" href="https://github.com/aspnetboilerplate/as">https://github.com/aspnetboilerplate/as</a> ... ssues/1706

But as you know my case is different. I have multiple databases and multiple db context. not a single database. can you provide other solution to solve this case ?

can you give me a sample solution?

please help me..

Answer

Hi,

Is that for multiple dbcontext with single database or multiple dbcontext with multiple database ?

Answer

Any help ??

Showing 1 to 10 of 25 entries