小编Kha*_*Ali的帖子

表达式不能包含lambda表达式

我已经获取了List<>下面的对象(with .Include()):

List<vDetail> entityvDetails =
    context.vDetails
    .Include("payInstallment.appsDetail")
    .Include("payInstallment.appsDetail.application")
    .Include("payInstallment.appsDetail.purposes")
    .Where(e => e.vch_id == 123).ToList();
Run Code Online (Sandbox Code Playgroud)

然后在前面的代码中的某处我尝试过滤实体记录,如下所示:

foreach (vDetail item in lstVDetails)
{
    ... 

    int purposeId = entityvDetails.Where(e => e.sad_id == item.sad_id).FirstOrDefault().payInstallment.appsDetail.purposes.prp_id;

    ...
}
Run Code Online (Sandbox Code Playgroud)

代码编译完美.但是,运行时返回跟随错误(尽管包括所有导航):

Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)

所以我设置使用监视窗口进行调试.现在在观察窗口中分析以下语句时:

entityVoucherDetails.Where(e => e.sad_id == item.sad_id).FirstOrDefault()
Run Code Online (Sandbox Code Playgroud)

监视窗口生成以下错误:

表达式不能包含lambda表达式.

如果有人能告诉我可能是什么原因?

c# linq lambda entity-framework entity-framework-4

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

SqlDependency.OnChange触发但SqlDataReader没有返回数据

当我使用datetime列过滤器执行查询时

WHERE [Order].CreatedOn >= @CreatedOn
Run Code Online (Sandbox Code Playgroud)

使用a SqlDependency,对数据源的更改将触发SqlDependency.OnChange事件,但SqlDataReader与之关联的SqlCommand不会返回数据(reader.HasRows始终返回false).

当我只是将我的SQL语句中的过滤条件更改为

WHERE [Order].StatusId = 1"
Run Code Online (Sandbox Code Playgroud)

它只是工作正常和SqlDataReader返回数据(reader.HasRows返回true)

码:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SignalRServer
{
    public partial class DepartmentScreen : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var u = System.Security.Principal.WindowsIdentity.GetCurrent().User;
            var UserName = u.Translate(Type.GetType("System.Security.Principal.NTAccount")).Value;

            CheckForNewOrders(DateTime.Now);
        }

        private void CheckForNewOrders(DateTime dt) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net sqldependency query-notifications signalr

9
推荐指数
1
解决办法
1181
查看次数

插件注册中未显示自定义工作流活动

有谁能在这里暗示我做错了什么?

我使用此示例创建了自定义工作流活动创建自定义工作流活动.但这并没有在插件注册工具中显示为插件/活动类型.见下图:

在此输入图像描述

我的活动示例代码如下:

代码更新

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace TestCustomWorkflowActivity
{
    public class SampleCustomActivity : CodeActivity
    {
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();

            //Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Platform
Dynamics CRM 2013 On Premises v 6.1.2.112(已安装SP1 UR2)
Dynamics CRM 2015 Online

.NET Framework
4.0

c# dynamics-crm workflow-foundation workflow-foundation-4 dynamics-crm-online

7
推荐指数
2
解决办法
3164
查看次数

Azure AD应用程序未出现在Azure Web应用程序的现有AD App列表中

我只是经历了一些演练,在其中我创建了一个Azure AD应用程序以将其用作Azure Web应用程序中的授权/身份验证。

现在,当我为我的Azure网站(应用程序服务)选择现有的AD应用程序时,它没有出现在我的Azure AD应用程序列表中。

添加现有AD应用程序的路径是“应用程序服务> MyAzureApp>身份验证/授权> Auzre Active Directory> Express>选择现有AD应用程序”

我为Azure AD应用程序使用了以下设置:

登录URL:https :
//login.windows.net

回复网址:https :
//msmanaged-na.consent.azure-apim.net/redirect

所需权限:
Azure服务管理API>以组织用户身份访问Azure服务管理

密钥:
添加了密钥并将其到期日期设置为1年

请帮忙。

更新(@dstrockis):
我将此粘贴到浏览器 https://login.microsoftonline.com/(tenantname).onmicrosoft.com/oauth2/authorize?client_id=(API Acces-Keys-GeneratedKey)=&redirect_uri =(https: //azuresitename.azurewebsites.net/.auth/login/aad/callback)&response_mode=query&response_type=code+id_token&scope=openid&nonce=12345

而且我有一个不好的要求。见下图

在此处输入图片说明

azure azure-web-sites azure-active-directory azure-web-app-service

6
推荐指数
1
解决办法
4046
查看次数

如何按有拼写错误的列分组

在处理一些遗留数据时,我想在忽略拼写错误的列上对数据进行分组。我认为 SOUNDEX() 可以完成这项工作以达到预期的结果。这是我尝试过的:

SELECT soundex(AREA)
FROM MASTER
GROUP BY soundex(AREA)
ORDER BY soundex(AREA)
Run Code Online (Sandbox Code Playgroud)

但是(显然)SOUNDEX 在这样的结果行中返回了 4 个字符的代码,丢失了实际的字符串:

A131
A200
A236
Run Code Online (Sandbox Code Playgroud)

如何将组中的至少一个事件包含在查询结果中,而不是包含 4 个字符的代码。

t-sql sql-server soundex group-by

5
推荐指数
2
解决办法
1347
查看次数

实体框架和SQL Server Profiler

在通过Web应用程序运行的EF查询与将Profiler生成的T-SQL直接运行到SQL Query窗口之间,我遇到了一些性能评估问题。

以下是通过Web应用程序执行的我的EF查询:

IEnumerable<application> _entityList = context.applications
                    .Include(context.indb_generalInfo.EntitySet.Name)
                    .Include(context.setup_budget.EntitySet.Name)
                    .Include(context.setup_committee.EntitySet.Name)
                    .Include(context.setup_fund.EntitySet.Name)
                    .Include(context.setup_appStatus.EntitySet.Name)
                    .Include(context.appSancAdvices.EntitySet.Name)
                    .Where(e => e.indb_generalInfo != null);

                if (isIFL != null)
                    _entityList = _entityList.Where(e => e.app_isIFL == isIFL);

                int _entityCount = _entityList.Count(); // hits the database server at this line
Run Code Online (Sandbox Code Playgroud)

在SQL Profiler中跟踪上述EF查询时,发现执行该操作大约需要221'095 ms。(具有30,000+的应用程序表,具有11,000+的indb_generalInfo和具有30,000+记录的appSancAdvices)。

但是,当我从Profiler复制T-SQL并直接从“查询”窗口运行它时,它只需要大约4000毫秒

为什么会这样呢?

c# performance entity-framework sql-server-profiler

3
推荐指数
1
解决办法
4352
查看次数

jQuery ajax data.d 未定义

我正在尝试使用 Ajax 调用获取 CRM 数据。数据返回带有 'd' 和 'result' 属性,但我无法在客户端获取它。它说 ajaxdata.d 是未定义的。

示例 Ajax 调用:

var context = Xrm.Page.context;
var serverUrl = context.getClientUrl();
var ODATA_ENDPOINT = context.prependOrgName("/xRMServices/2011/OrganizationData.svc");

var filter = "?&$select=cc_TypeID,cc_customentityId,cc_anotherAttribute&$filter=cc_TypeID eq '2'";

var odataUri = ODATA_ENDPOINT + "/cc_customentitySet" + filter;

console.log("odataUri: " + odataUri);

//Asynchronous AJAX function to Retrieve a CRM record using OData
$.ajax({
    type: "GET",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    url: odataUri,
    async: false,
    beforeSend: function (XMLHttpRequest) {
        //Specifying this header ensures that the results will be returned …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery dynamics-crm

3
推荐指数
1
解决办法
3057
查看次数

仅在JavaScript字符串中选择数字

我想从给定的字符串中选择所有数字.我尝试使用下面的代码,但它不返回字符串中的所有数字:

var match = /\d+/.exec("+12 (345)-678.90[]");
console.log(match.toString());
Run Code Online (Sandbox Code Playgroud)

它只返回12,而我希望它返回1234567890.

javascript regex jquery

3
推荐指数
1
解决办法
88
查看次数

将CheckBoxList绑定到通用列表

如何将CheckBoxList绑定到通用列表对象.此示例代码应该用于此目的:

protected void Page_Load(object sender, EventArgs e)
{
    // Works well with the datatable as a data source
    //DataTable _entityList = new DataTable();
    //_entityList.Columns.Add("Id", typeof(int));
    //_entityList.Columns.Add("ProductName", typeof(string));
    //_entityList.Rows.Add(new object[] { 1, "First" });
    //_entityList.Rows.Add(new object[] { 2, "Second" });

    // Doesn't work with the generic list as a data source
    List<MyProduct> _entityList = new List<MyProduct>();
    _entityList.Add(new MyProduct(1, "First"));
    _entityList.Add(new MyProduct(2, "Second"));

    cblProducts.DataSource = _entityList;
    cblProducts.DataTextField = "ProductName";
    cblProducts.DataValueField = "Id";
    cblProducts.DataBind();
}

public class MyProduct
{
    public int Id;
    public …
Run Code Online (Sandbox Code Playgroud)

c# asp.net data-binding checkboxlist

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

LINQ语句Where子句中的子查询

所以我试着按照这个例子在这个LINQ查询的where子句中有一个子查询.

var innerquery =
    from app in context.applications
    select new { app.app_id };

IEnumerable<postDatedCheque> _entityList = context.postDatedCheques
    .Where(e => innerquery.Contains(e.appSancAdvice.application.app_id));
Run Code Online (Sandbox Code Playgroud)

其目的是选择那些记录postDatedChequesAPP_ID应用程序表.

但是我在where子句中跟踪了错误:

  1. 委托'System.Func'不带1个参数
  2. 无法将lambda表达式转换为类型'string',因为它不是委托类型
  3. 'System.Linq.IQueryable'不包含'Contains'的定义和最佳扩展方法重载'System.Linq.ParallelEnumerable.Contains(System.Linq.ParallelQuery,TSource)'有一些无效的参数
  4. 实例参数:无法从'System.Linq.IQueryable'转换为'System.Linq.ParallelQuery'

我的编码错误是什么?

c# linq asp.net linq-to-entities entity-framework

0
推荐指数
2
解决办法
2万
查看次数