Base solution for your next web application

Activities of "ipservant"

Thank you, that works fine!

Thank you, that worked!

Answer

Hello, I'm trying to do the same and deleted the .EntityFrameworkCore/Migrations folder's Migration classes but not the Seed folder and it's contents. Add-Migration and Update-Database went well:

PM> add-migration Initial_Migration Build started... Build succeeded. To undo this action, use Remove-Migration. PM> update-database Build started... Build succeeded. Applying migration '20200122140256_Initial_Migration'. Done.

But after launching the host I get this error:

Npgsql.PostgresException HResult=0x80004005 Message=42P01: Relation »AbpEditions« existiert nicht Source=Npgsql

What am I doing wrong? Thanks for help!

I found a solution by myself that I wanted to share with you, feel free to let me know what you think of it. I extended PrimengTableHelper.ts with:

    getMultiSorting(table: Table): string {
        let sorting;
        if (table.multiSortMeta != undefined && table.multiSortMeta.length > 0) {
            sorting = '';
            for (let i = 0; i < table.multiSortMeta.length; i++) {
                if (table.multiSortMeta[i]) {
                    sorting += table.multiSortMeta[i].field;
                    if (table.multiSortMeta[i].order === 1) {
                        sorting += ' ASC';
                    } else if (table.multiSortMeta[i].order === -1) {
                        sorting += ' DESC';
                    }
                    if ((i + 1) < table.multiSortMeta.length) {
                        sorting += ', ';
                    }
                }
            }
        }

Core then uses OrderBy:

.OrderBy(input.Sorting ?? "id asc")

Kind regards, IPS

First of all thanks. In the test program it works. Even though I don't understand yet, why. And only the Async version. Trying the same on the non-async will not lead to a success. But let's digg deeper into the root causes. Your** Abp.NHibernate asm** and there the AbpNHibernateModule does some more magic, which I could not replicate yet. The thing is: I certainly tried to depend on the NHModule already a while ago:

//[DependsOn(typeof(AbpNHibernateModule))]
[DependsOn(typeof(IPSwebCoreModule))]
public class IPSwebAdsDataModule : AbpModule
{

but it turns out that once enabled, the module registers all standard facilties on it's. So all the other IRepository<T>s or similar end up becoming an NHibrernate Repo. So the whole existing EF-Based application does not work anymore. Example-Exception below. Sorry but I have to have two OR-Mappers in my application for two very differend DBMSs.

So what do I need to register differently or do different in my SessionProvider? I suppose, I have to register a shim in Kestrel to create the (NH-based) wrapping transactions before any call to a NH-Reposoitory....

Hmm. So this happens if the Module dependency is declared: Also the User repository is realized as NH as the facility is now on NH

HibernateException: Unable to locate persister for the entity named 'IPSweb.Authorization.Users.User'.
The persister define the persistence strategy for an entity.
Possible causes:
- The mapping for 'IPSweb.Authorization.Users.User' was not added to the NHibernate configuration.
NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
Stack Query Cookies Headers 
HibernateException: Unable to locate persister for the entity named 'IPSweb.Authorization.Users.User'. The persister define the persistence strategy for an entity. Possible causes: - The mapping for 'IPSweb.Authorization.Users.User' was not added to the NHibernate configuration. 
NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
NHibernate.Impl.SessionImpl.Get(string entityName, object id)
NHibernate.Impl.SessionImpl.Get<T>(object id)
Abp.Domain.Repositories.AbpRepositoryBase<TEntity, TPrimaryKey>.FirstOrDefaultAsync(TPrimaryKey id) in AbpRepositoryBase.cs
Castle.Proxies.Invocations.IRepository`2_FirstOrDefaultAsync_8.InvokeMethodOnTarget()
Castle.DynamicProxy.AbstractInvocation.Proceed()
Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) in UnitOfWorkInterceptor.cs
Castle.DynamicProxy.AbstractInvocation.Proceed()
Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) in UnitOfWorkInterceptor.cs
Castle.DynamicProxy.AbstractInvocation.Proceed()
Castle.Proxies.IRepository`2Proxy_2.FirstOrDefaultAsync(long id)
Abp.Authorization.Users.AbpUserStore<TRole, TUser>.FindByIdAsync(string userId, CancellationToken cancellationToken) in AbpUserStore.cs

Yes. i am happy to do so. As it will be the stripped down project of the ongoing development, can I send it to you as a PM?

Sorry I have to reopen this. I desperately need a success.

I created a test project using bare NHibernate. I even used the same Entities and the same table(file) ... it worked. So why would it not work with ABP in addition? The test project is able to read the table and insert into it (just after calling Flush). The Entity class looks nearly the same so does the hbm.xml. So far it uses a different ID generator but that generator has never really been the problem. I even replaced it with the same uuid.hex but it makes no differnce. It is actually the only piece that produces SQL towards the DB.

Still my problem is: I can select data out of ABP using NHibernate and my funky DBMS. BUT I cannot Insert any data. (seemingly rolled back?) NO Exceptions happen if the supposed code is running.

Now I am fiddling in the object trees of the UnitOfWork stuff and transactions. Because my suspicion is that somehow a rolback happens. When I use a UnitOfWork-Manager and/or an [UnitOfWorkAttribute], I can see three filters in Abp.Runtime.Session.ClaimsAbpSession

  1. SoftDelete (enabled)
  2. MustHaveTenant (diabled)
  3. MayHaveTenant (enabled)

More things to considder are:

  • The result of me 'calling' my controller is : {"result":null,"targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}
  • In order to be faster in testing, I created an unauthenticated simple Controller that I can 'directly call' from the web browser. Thus I am not logged in, which may be a problem.
  • When I do both, BeginWork with a UnitOfWorkManager plus have the Attribute, I end up getting this:

Abp.AbpException: "Did not call Complete method of a unit of work."

In order to make it work in my test project I had to call Session.Flush()

            OBJEKTE o = new OBJEKTE()
            {
                ID_AKTE = "0000001235",
               ...
                ONLDATUM = System.DateTime.UtcNow,
                SAFETYLVL = "",
                ONLSTATUS = "",
                DATFTS = null,
            };
            List<OBJEKTE> all = sess.Query<OBJEKTE>().ToList();

            string generatedId = (string)sess.Save(o);
            sess.Flush();

I have the same or a similar Problem after upgrading my source code with the Version 6.7. Must have overtaken like 2 minor versions.

I was able to track it down from

     public override void PostInitialize()
    {
        IocManager.RegisterIfNot&lt;IChatCommunicator,             NullChatCommunicator&gt;();
       IocManager.Resolve&lt;ChatUserStateWatcher&gt;().Initialize();
        
        ..
        //which needs 
        IocManager.Resolve&lt;IUserFriendsCache&gt;();
        //which needs
        IocManager.Resolve&lt;UserManager&gt;();
        //which needs
        var user = IocManager.Resolve&lt;UserStore&gt;();
        //which has apparently a circular reference (see above)

what should we do. Looks harmful to me if no UserManager is there.

OK, I came up with something and I share this with you here: Maybe there is also some inspiration for the future framework.

Essentially I went without initializing the Abp.NHibernate module plus creating my own ISessionFactory singleton which is initialized in PreInitialize().

//[DependsOn(typeof(AbpNHibernateModule))]
[DependsOn(typeof(IPSwebCoreModule))]
public class MyAppAdsDataModule : AbpModule
{
        private ISessionFactory _sessionFactory;
    public override void PreInitialize()
    {
        var connStr = _appConfiguration["ConnectionStrings:AdsConnString"];

        var cfg = new NHibernate.Cfg.Configuration();
        _sessionFactory = Fluently.Configure(cfg)
            .Database(AdsIntegration.ConnectionString(connStr))
            .Mappings(m => m.HbmMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
            .BuildSessionFactory();
    }

Problems arose with satisfying my Repoisitoy class - winsor-castle did not know how to resolve my custom repo.

public class KarteiRepository : AdsRepositoryBase&lt;KARTEIKARTE, int&gt;, IKarteiRepository
{
    public KarteiRepository(INhMySessionProvider sessionProvider) : base(sessionProvider)
    {
    }

In order to avoid clashes (my code used to use ISessionProvider as ctor-Param. So I created my own INhMySessionProvider and programmed it like this:

public interface INhMySessionProvider : ISessionProvider
{ }

public class NhMySessionProvider : INhMySessionProvider
{
    private readonly ISessionFactory f;

    public NhMySessionProvider(ISessionFactory f)
    {
        this.f = f;
    }

    public ISession Session
    {
        get
        {
            return f.OpenSession();
        }
    }
}

Then, the only thing needed to to (to let it be resolved) was to add some lines to my Data module's initialize method:

    public override void Initialize()
    {
        IocManager.IocContainer.Register(
            Component.For&lt;ISessionFactory&gt;().Instance(_sessionFactory).LifeStyle.Singleton,
            Component.For&lt;INhMySessionProvider&gt;().ImplementedBy&lt;NhMySessionProvider&gt;().LifeStyle.Transient);

        IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
    }

PS. AdsIntegration.ConnectionString(connStr) is my customization for SAP Advanced DB. but this is a different topic.

So eventually I did not need Apb.NHibernate. Still my reference is there... let's see

I managed to create a separate NHibernate assembly for the DB access and the custom repositories (ones that inherit IRepository) plus a MyAppNhRepositoryBase abstract base implementation. I still have my Module a such:

[DependsOn(typeof(AbpNHibernateModule))]
[DependsOn(typeof(IPSwebCoreModule))]
public class MyAppdsDataModule : AbpModule
{

Now what happens depends on the order on my main module.

if the order of the attributes is like so:

    [DependsOn(
    typeof(MyAppEntityFrameworkCoreModule),
    typeof(MyAppNHibDataModule),
    ...
    typeof(AbpHangfireAspNetCoreModule) 
)]
public class MyAppWebCoreModule : AbpModule
{

I get this exception at startup in UnitOfWorkBase.cs: System.InvalidCastException: "Unable to cast object of type 'Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork' to type 'Abp.NHibernate.Uow.NhUnitOfWork'." .. and similar ones

however if the oder is reverse like so:

    [DependsOn(
    typeof(MyAppNHibDataModule),
    typeof(MyAppEntityFrameworkCoreModule),
    ...
    typeof(AbpHangfireAspNetCoreModule) 
)]
public class MyAppWebCoreModule : AbpModule
{

The result is that IRepository<User> gets resolved with an NH-Implementation of IRepository.

I understand, why that happens and I know that castle windsor can be highly customized. But I rather want to ask especially what or how I should customize the resolution/registration of types.

  1. Is it at all possible to use NH and the AbpNHibernateModulein conjunction with EF?
    1. Or will it clash central components?
  2. If yes, how can it be accomplished and is there a forseen way?
  3. Can I claim land if I omit dependency of AbpNHibernateModule and register the AbpNHibernate classes myself with WC?
Showing 21 to 30 of 30 entries