Base solution for your next web application

Activities of "cosmic"

Did you read the documentation? [http://aspnetboilerplate.com/Pages/Documents/Caching#configuration])

Default expire times can you see here: [https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/AbpKernelModule.cs#L119])

Hi, I implemented OU based on documentation at [http://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units#filter-entities-for-a-user]). I'm using a method that gets entities in user's OUs including their child OUs. (method GetProductsForUserIncludingChildOusAsync(long userId) in documentation). Every time I call a method, I'm getting following error:

The specified LINQ expression contains references to queries that are associated with different contexts.
System.NotSupportedException: The specified LINQ expression contains references to queries that are associated with different contexts.
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.InlineObjectQuery(ObjectQuery inlineQuery, Type expressionType)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.InlineValue(Expression expression, Boolean recompileOnChange)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.Expressions.EntityExpressionVisitor.VisitMethodCall(MethodCallExpression m)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.FuncletizingVisitor.Visit(Expression exp)
   at System.Data.Entity.Core.Objects.ELinq.Funcletizer.Funcletize(Expression expression, Func`1& recompileRequired)
   at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter..ctor(Funcletizer funcletizer, Expression expression)
   at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.CreateExpressionConverter()
   at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)

I'm using no tenants, single DB. My LINQ query is exactly as in documentation. Any idea how to solve this? Thanks.

Hi, this is a default behavior of the IIS. It will suspend application after 20 minutes (default setting) of inactivity. You can implement own functionality to "keep alive" the application. See: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/460">https://github.com/aspnetboilerplate/as ... issues/460</a>

Here is my machine controller:

public class MachinesController : AdminControllerBase
{
    private readonly IMachineAppService _machineAppService;

    public MachinesController(IMachineAppService machineAppService)
    {
        _machineAppService = machineAppService;
    }
    
    public async Task<JsonResult> GetStatus(int id)
    {
        var input = new GetMachineStatusInput
        {
            Id = id
        };
        var output = await _machineAppService.GetStatusAsync(input);
    
        return Json(new MvcAjaxResponse(output.Response.Status), JsonRequestBehavior.AllowGet);
    }
}

Hi, [Abp.WebApi.Authorization.AbpApiAuthorize] attribute is for usage with Web API, not for application services. See: [http://aspnetboilerplate.com/Pages/Documents/Authorization])

Hi, I found a very interesting thing.

When I'll use [AbpAuthorize] attribute on any application service and then I'll call this service direct through the JavaScript, like this:

abp.services.app.machine.getStatusAsync({
    id: machineId
}).done(function (data) {
    // some code
});

Then the data.result will be always "No user logged in!". But user is logged in and he has full permissions.

But, when I'll call through the MVC controller the same app service still with the [AbpAuthorize] attribute, like this: JavaScript

$.get(url, { id: machineId }).done(function (response) {
    abp.message.info(response.result);
});

MVC Controller

public async Task<JsonResult> GetStatus(int id)
{
    var input = new GetMachineStatusInput
    {
        Id = id
    };
    var output = await _machineAppService.GetStatusAsync(input);

    return Json(new MvcAjaxResponse(output.Response.Status), JsonRequestBehavior.AllowGet);
}

Then the expected result will be returned.

Why this is happening? How I can resolve this?

Hello, I found in the application log file following warning:

WARN|Abp.Domain.Uow.CallContextCurrentUnitOfWorkProvider|There is a unitOfWorkKey in CallContext but not in UnitOfWorkDictionary!

This warning message is repeatedly added into the log file every few seconds. What does it mean? How I can fix this?

Answer

I have opened an issue on DynamicFilters Github page. In my case both IMustHavePlace and IMayHavePlace filters throws null reference exception.

Can you please test and confirm that the Contains() operator works correctly with data filters in the ABP framework? Thank you very much.

#Edit: I also tried to generate a new Module Zero template and implement only those models and interfaces as described in [https://github.com/jcachat/EntityFramework.DynamicFilters/issues/45]). This produce the same error.

Answer

Yes, I did. If I use the List, it's not working. But if I use only one value, like defined for IMayHaveTenant, it is working.

Question

Hello, I followed your documentation about Data Filters to create my custom filters, but without success. I need a filter with the support of a list of int values.

Example:

var placeIds = new List<int> { 1, 2, 3, 4, 5 };

I have tried following in my DB context, as suggested at [https://github.com/jcachat/EntityFramework.DynamicFilters])

var values = new List<int> { 1, 2, 3, 4, 5 };
var values2 = new List<int?> { null, 1, 2, 3, 4, 5 };
modelBuilder.Filter(DataFilters.MustHavePlace, (IMustHavePlace p, List<int> placeList) => placeList.Contains(p.PlaceId), values);
modelBuilder.Filter(DataFilters.MayHavePlace, (IMayHavePlace p, List<int?> placeList) => placeList.Contains(p.PlaceId), values2);

When I'll try to run the application, it will always return following exception:

ERROR|Abp.Web.Mvc.Controllers.AbpHandleErrorAttribute|System.NullReferenceException: Object reference not set to an instance of an object.
   at EntityFramework.DynamicFilters.DynamicFilterExtensions.SetSqlParameters(DbContext context, DbCommand command)
   at EntityFramework.DynamicFilters.DynamicFilterCommandInterceptor.SetDynamicFilterParameterValues(DbCommand command, DbContext context)
   at EntityFramework.DynamicFilters.DynamicFilterCommandInterceptor.ReaderExecuting(DbCommand command, DbCommandInterceptionContext`1 interceptionContext)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClass7.&lt;GetResults&gt;b__5()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at System.Linq.Queryable.Count[TSource](IQueryable`1 source)

What is wrong?

Showing 1 to 10 of 27 entries