"Could not parse expression '...: The given arguments did not match the expected arguments" [closed]

1

I am using the CompiledQueries feature of the framewok core 2.0 entity but even though it does not syntax error, when the program is running, I get this exception:

  

Could not parse expression 'value   (Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable'1   [TaskManager.Entities.EntitiesDB.USER]) AsNoTracking (). Onde (__   conditions) ': The given arguments did not match the expected   arguments: Object of type   'System.Linq.Expressions.TypedParameterExpression' can not be   converted to type 'System.Linq.Expressions.LambdaExpression'.

I have no idea what it is. I Need help.

Here is the source code of my repository which displays this error:

/// <summary>
/// Query of user
/// </summary>
/// <param name="_context">context</param>
/// <param name="conditions">conditions for clause "Where"</param>
/// <returns>first task that meets the conditions or null </returns>
private static Func<Context, Func<USER, bool>, Task<UserResponseDTO>> _getUser = EF.CompileAsyncQuery 
(
   (Context _context, Func<USER, bool> conditions) =>
      (conditions == null)? 
          _context.USER.Select(user =>
              new UserResponseDTO {
                NAME = user.NAME,
                EMAIL = user.EMAIL,
                SEQUSER = user.SEQUSER,
                DATEREGISTER = user.DATEREGISTER
              }
           ).AsNoTracking().FirstOrDefault ()
      :                                        
          _context.USER.AsNoTracking()
          .Where(conditions).Select(user =>
              new UserResponseDTO {
                NAME = user.NAME,
                EMAIL = user.EMAIL,
                SEQUSER = user.SEQUSER,
                DATEREGISTER = user.DATEREGISTER
              }
           ).FirstOrDefault ()
);

My class that implements DbContext:

public class Context: DbContext
{
    public Context(DbContextOptions<Context> options): base(options){ }
    public virtual DbSet<USER> USER { get; set; }
    public virtual DbSet<TASK> TASK { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder){
        #region Sequences

        modelBuilder.HasSequence<long> 
        ("S_SEQUSER").StartsAt(1).HasMin(1);
        modelBuilder.HasSequence<long> 
        ("S_SEQTASK").StartsAt(1).HasMin(1);                   

        #endregion

        #region propeties Mapping
        modelBuilder.Entity<USER>()
            .Property(u => u.SEQUSER)                
            .HasDefaultValueSql(" nextval('\"S_SEQUSER\"') ");

        modelBuilder.Entity<TASK>()
           .Property(u => u.SEQTASK)            
           .HasDefaultValueSql(" nextval('\"S_SEQTASK\"') ");

        modelBuilder.Entity<USER>()
        .HasMany(u => u.TASK)
        .WithOne(u => u.USER);   
        #endregion        

        base.OnModelCreating(modelBuilder);
    }
}

my database entity:

/// <summary>
/// query user
/// </summary>
[Table(@"USER")]
public class USER
{
    #region Properties
    /// <summary>
    /// sequence of user
    /// </summary>
    /// <value></value>
    [Key()]
    [Column(@"SEQUSER")]
    public virtual long SEQUSER { get; set; }

    /// <summary>
    /// email of user
    /// </summary>
    /// <value></value>
    [Required]
    [StringLength(120)]
    [Column(@"EMAIL")]
    public virtual string EMAIL { get; set; }

    /// <summary>
    /// password of user
    /// </summary>
    /// <value></value>
    [Required]
    [StringLength(15)]
    [Column(@"PASSWORD")]
    public virtual string PASSWORD { get; set; }

    /// <summary>
    /// name of user
    /// </summary>
    /// <value></value>
    [Required]
    [StringLength(120)]
    [Column(@"NAME")]
    public virtual string NAME { get; set; }        

    /// <summary>
    /// date of user was registered
    /// </summary>
    /// <value></value>
    [Column(@"DATEREGISTER")]
    public virtual DateTime DATEREGISTER { get; set; }

    /// <summary>
    /// last acess of user in application
    /// </summary>
    /// <value></value>
    [Column(@"LASTACESS")]
    public virtual DateTime LASTACESS { get; set; }

    /// <summary>
    /// list of task 
    /// </summary>
    /// <value></value>
    [InverseProperty("USER")]
    public virtual List<TASK> TASK { get; set; }

    #endregion    
}

Could someone give me a hand at this?

    
asked by anonymous 08.09.2018 / 09:26

0 answers