小编use*_*731的帖子

C#linq包括before-after之后

在linq之间有区别:

EFDbContext _db = new EFDbContext();



  1)_db.UserQuizes
        .Where(uq => uq.UserId == currentUserId && uq.QuizId == quizId)
        .Include(qz => qz.Quiz.VerbalQuizes.Select(q => q.Question)).First()

2)_db.UserQuizes
        .Include(qz => qz.Quiz.VerbalQuizes.Select(q => q.Question))                          
        .Where(uq => uq.UserId == currentUserId && uq.QuizId == quizId).First()

   3)_db.UserQuizes
            .Include(qz => qz.Quiz.VerbalQuizes.Select(q => q.Question))
             First(uq => uq.UserId == currentUserId && uq.QuizId == quizId)
Run Code Online (Sandbox Code Playgroud)

请注意,第一个查询使用包括在where之前和之后的where,但结果是相同的.另外如何查看实际的sql查询?在这个特殊情况下,性能是我的主要目标,我可以改进查询吗?我需要更改两个属性:UserQuizes属性和UserQuizes-> VerbalQuizes-> Question属性.

将它分成两个查询或者像它一样使用它会更好吗?

c# linq entity-framework

15
推荐指数
1
解决办法
4608
查看次数

用户很快就会退出

我正在使用ASP.NET身份会员资格.这是Startup.Auth.cs代码:

 app.CreatePerOwinContext(EFDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

        // Enable the application to use a cookie to store information for the signed in user
        // and to use a cookie to temporarily store information about a user logging in with a third party login provider
        // Configure the sign in cookie
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),  
            ExpireTimeSpan = TimeSpan.FromHours(3),
            CookieName = "MyLoginCookie",

            Provider = new CookieAuthenticationProvider
            {
                // Enables the application to validate the security stamp when the user …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc identity

5
推荐指数
1
解决办法
1421
查看次数

匿名选择中的C#linq增量变量

在 linq 中是否可以在匿名选择中增加变量?

例如,这是我的代码:

   int[] coefficients = { 1, 2, 3, };
   int i = 0;

   var verbalResult =
                  from fq in finishedQuizzes
                  from vq in fq.Quiz.VerbalQuizes
                  group vq by vq.Question.ExamTagId into r
                  select new
                  {
                      Tag = r.First().Question.ExamTag.Name,                 
                      CorrectAnswerCount = r.Sum(e => e.ISMovedAnswerCorrect ? 1 : 0),
                      questionCount = r.Count(),
                      coefficient = coefficients[i],
                      i++
                  };
Run Code Online (Sandbox Code Playgroud)

我想通过索引(i)获得系数。我可以i像这样增加变量吗?

c# linq

2
推荐指数
1
解决办法
3339
查看次数

快速搜索Acumatica过滤PXSelector

我有一个像这样的自定义dac和pxselector:

在此处输入图片说明 通过快速搜索(红色边框搜索),我想对每个属性进行过滤。例如,运单类型,运输类型,状态等。但是快速搜索仅适用于参考Nbr。

当然,您可以从列中进行过滤,但是在业务需求中,我需要从快速搜索中进行过滤。

acumatica

2
推荐指数
1
解决办法
517
查看次数

标签 统计

c# ×3

linq ×2

acumatica ×1

asp.net-mvc ×1

entity-framework ×1

identity ×1