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

Activities of "bilalhaidar"

Yes :)

I thought of not deleting the post in case someone else faced the issue.

Regards Bilal

I was missing this reference:

using Abp.Linq.Extensions;

Regards Bilal

Maybe I should have defined the Id in CacheItem as of type TPrimaryKey, then it will work.

Thanks, I didn't find the thread useful. There was no solution.

The one thing I figured out is maybe I should have defined another class that inherits from the ReferenceDataManager in my case and used concrete types something like:

public class ConcreteReferenceDataManager : ReferenceDataManager<HostEntityBase, int>

Then in this class I can implement caching since all types are known.

Problem is when I had a CacheItem with Id of type int, I was storing the cache item in Cache. But then I had to map back to a type whose Id is of type TPrimaryKey. so I guess it doesnt work like that.

I saw many examples in your code, but none tries to store a concrete object and then retrieve it as a generic object.

Actually you need to do it on the client and server side.

You mean that on the server-side I write the code that will return the meta data for a form (which fields to show and hide). On the client side I use Angular to show/hide.

Originally I thought in addition to writing code on server side to know what field to show and what to hide, I thought I can do the filtering on razor view server side rather than angular.

By the way, what's your first name?

Problem solved.

My entity belongs to a Tenant. I was not supplying TenantId for the entity.

In case someone faces same issue, you just make sure to set TenantId on the new entity.

Regards Bilal

Thanks :) As long as I don't hit Update-Database should be fine :)

Thank you.

But I meant that one method returns Task<IdentityResult> and the other results Task.

Thanks

On the client side (angular) you mean?

My problem is, I am storing in cache a class having Id of type object. Then, I am trying to map a non-generic instance to a generic-instance.

I ended up storing the HostEntityBase<T> in cache, this way, when I retrieve data I don't have to map or convert. I am not sure this is the correct way,

Can you please check if this ok or you suggest any enhancement? My only worries is that the HostEntityBase<T> has few methods and I was planning to store pure data in cache that is why I created the CacheItem above.

Thank you :)

public class HostEntityCacheItem<THostEntityBase>
    {
        public static string CacheStoreName = $"Drc{typeof(THostEntityBase).FullName.ToString()}";

        public List<THostEntityBase> Items { get; set; }

        public HostEntityCacheItem()
            :this(new List<THostEntityBase>())
        {
        }

        public HostEntityCacheItem(List<THostEntityBase> list)
        {
            Items = new List<THostEntityBase>(list);
        }
    }

        [UnitOfWork]
        private async Task<HostEntityCacheItem<THostEntityBase>> GetListFromCacheAsync()
        {
            return await CacheManager.GetHostEntityCache<THostEntityBase>().GetAsync(GenerateDefaultCacheKeyName(),
                async () =>
            {
                //Get a list from the database
                var list = (await GetHostEntityFromDatabaseAsync());

                return new HostEntityCacheItem<THostEntityBase>(list);
            });
        }
Showing 391 to 400 of 461 entries