Base solution for your next web application

Activities of "theedge"

Hi Halil,

I am not storing NULL values in the cache. The exception is being thrown when their is no match in the cache. Not sure if it has to do with the fact that the value type of int can be NULL?

For what it is worth I modified my code (unsing 0.7.4.1) to use Get() instead of GetOrDefault(), leaving everything else unchanged and the exception went away.

Hi Halil,

My key is not null as far as I am aware. My cache is empty and I am supplying a key value from my passed in value of aParams.BrandSeoFriendly which is the string "celebrity-cruises".

So is it possible that if there is no value associated with the key that the hard cast of:

(TValue)cache.GetOrDefault(key.ToString())

is failing? Wouldn't soft cast of:

cache.GetOrDefault(key.ToString()) as (TValue)

be better? It seems to me that this issue is because the associated value is actually an INT.

Bump!!!

Hi Halil,

Yep both of those references are not NULL. Here is the call stack as requested:

[NullReferenceException: Object reference not set to an instance of an object.]
   Abp.Runtime.Caching.CacheExtensions.GetOrDefault(ICache cache, TKey key) +53
   OzCruisingPlatform.Application.Services.Cache.OzCpCacheService.GetReferenceBrandBySeoFriendlyName(OzCpGetReferenceBrandBySeoFriendlyNameInput aParams) in D:\Data\TFS\Ozcruising\VS 2015\OzCruisingPlatform\OzCruisingPlatform.Application\Services\Cache\OzCpCacheService.cs:86
   Castle.Proxies.OzCpCacheServiceProxy.GetReferenceBrandBySeoFriendlyName_callback(OzCpGetReferenceBrandBySeoFriendlyNameInput aParams) +56
   Castle.Proxies.Invocations.IOzCpCacheService_GetReferenceBrandBySeoFriendlyName.InvokeMethodOnTarget() +179
   Castle.DynamicProxy.AbstractInvocation.Proceed() +110
   Castle.DynamicProxy.AbstractInvocation.Proceed() +447
   Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) +62
   Castle.DynamicProxy.AbstractInvocation.Proceed() +447
   Castle.DynamicProxy.AbstractInvocation.Proceed() +447
   Castle.DynamicProxy.AbstractInvocation.Proceed() +447
   Castle.Proxies.OzCpCacheServiceProxy.GetReferenceBrandBySeoFriendlyName(OzCpGetReferenceBrandBySeoFriendlyNameInput aParams) +255
   CruisesDesktop.Web.Controllers.CruisesController.ByBrand(String aBrandNameSeoFragment) in D:\Data\TFS\Ozcruising\VS 2015\CruisesDesktop\Cruises.Web\Controllers\CruisesController.cs:37
   lambda_method(Closure , ControllerBase , Object[] ) +141
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +228
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +38

Hi,

I am using ABP 0.7.3.

I have a cache service that uses IoC to inject a ICacheManager. This cache service is created from the constructor of my MVC controller also using IoC.

I call the cache service from a method off the above controller and get a NullReference exception. I read the doco about not calling GetCache() in a constructor, but as this is ultimately being called from a regular controller method it is not that.

I include a screenshot of my code (attached) showing that all the necessary objects are instantiated.

Any pointers greatly appreciated.

That is a big ask. You are better off having a read of the code and reading up on design patterns so you can recognise what is being used. Some patterns that are being used are Singleton, Inversion Of Control.

Bump! Halil - any insights you can offer here?

Hi,

  • Assume I have 3 tables named TableA, TableB, TableC
  • And a stored proc name StoredProc that makes use of all 3 tables with some form of JOIN

I would now like to access the StoredProc in my implementation of IApplicationService from the service layer.

So typically I have done:

public interface ITableARepository : IRepository<TableA, long>
 {
     //Internally uses DbContext to call the SP  
      void CallStoredProc();
 }

public interface IMyService : IApplicationService
 {
        void CallMyStoredProc();
}

public class MyService : IMyService
{   
  private  ITableARepository _TableArepository; 

  public MyService(ITableARepository aTableARepository)    
   {
         _TableARepository = aTableARepository;
   }

          public void CallMyStoredProc()
         {
                _TableARepository.CallStoredProc()
         }
}

However as the stored proc can access all the 3 tables invariably someone goes looking for it off TableBRepository or TableCRepository instead of TableARepository. As I don't want to pass a DBContext to my application service layer as that is a concrete and not an interface, what is a better way to do this?

Namely what is a "good" way to allow access to stored procedures without "tying" them arbitrarily to a repository interface? All the examples on ABP don't talk about stored procedures so I am looking for some guidance.

All pointers and suggestions appreciated.

Can you supply some code?

Thanks Halil, missed the SaveChanges() bit. I now have this working as I want it.

Showing 31 to 40 of 47 entries