标签: query-expressions

F#查询表达式"字段,构造函数或成员'包含'未定义"

我试图从Query Expressions页面获取此示例.我已经有了数据库设置,并且我已经编写了许多小代码.

    let idQuery = query { for id in [1; 2; 5; 10] do
                  select id }

    query { 
       for student in db.Student do
       where (idQuery.Contains(student.StudentID))
       select student
    }
Run Code Online (Sandbox Code Playgroud)

但我得到的只是错误:

未定义字段,构造函数或成员"包含"

我错过了什么?我还有其他的例子可供使用.

f# query-expressions

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

如何使用查询表达式crm进行内部连接

我正在尝试使用Query Expression进行简单的内部联接.我试图用QE转换这个查询,但我总是得到同样的错误.我正在做这个QE:

Entity Role = new Entity();
Role.LogicalName = "role";

Entity SystemUserRoles = new Entity();
SystemUserRoles.LogicalName = "systemuserroles";

QueryExpression query = new QueryExpression() {
  Distinct = false, EntityName = Role.LogicalName, ColumnSet = new ColumnSet("name"),

  LinkEntities = {
    new LinkEntity {
      JoinOperator = JoinOperator.Inner, LinkFromAttributeName = "roleid", LinkFromEntityName = Role.LogicalName, LinkToAttributeName = "roleid", LinkToEntityName = SystemUserRoles.LogicalName,
    }
  },

  Criteria = {
    Filters = {
      new FilterExpression {
        FilterOperator = LogicalOperator.And, Conditions = {
          new ConditionExpression("systemuserid", ConditionOperator.Equal, "9b1bf31d-ac29-e211-9826-00155d0a0b0f"),

        },
      },

    }
  } …
Run Code Online (Sandbox Code Playgroud)

sql-server query-expressions dynamics-crm-2011

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

Mobile Services query exception

When I use code with generic:

    var parenttable = MobileService.GetTable<TParent>();
    var testid = await parenttable.Where(prnt => prnt.Id == 20).ToListAsync();
Run Code Online (Sandbox Code Playgroud)

where TParent: IEnity

public interface IEnity
{
    int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

I catch the exception:

The member 'Id' is not supported in the 'Where' Mobile Services query expression 'Convert(prnt).Id'.

But if I change the generic to type:

   var parenttable = MobileService.GetTable<Category>();
   var testid = await parenttable.Where(prnt => prnt.Id == 20).ToListAsync();
Run Code Online (Sandbox Code Playgroud)

I have normal result. Why? And how can …

c# azure query-expressions azure-mobile-services

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

dynamo db的过滤器表达式中的OR条件

我有一个用例,需要使用dynamo db查询表达式以编程方式查询dynamo db。假设A和B有两个属性,我想要一个类似的过滤器表达式(A='Test' OR A ='Test1') and B='test2'

我搜索与此相关,但找不到有用的资源。我是dynamo db的新手。

query-expressions amazon-web-services amazon-dynamodb

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

如何在LinkEntity中使用条件和过滤器?

我想创建一个QueryExpression来模拟这个SQL语句

select * from A
inner join B on A.b_id=B.ID
where B.Name like "% what ever %"
Run Code Online (Sandbox Code Playgroud)

这就是FetchXML的样子

<?xml version="1.0" encoding="UTF-8"?>
<fetch distinct="true" mapping="logical" output-format="xml-platform" version="1.0">
   <entity name="A">
      <attribute name="ID" />
      <attribute name="sce_name" />
      <link-entity name="B" alias="ab" to="b_id" from="A">
         <filter type="and">
            <condition attribute="Name" value="% what ever %" operator="like" />
         </filter>
      </link-entity>
   </entity>
</fetch>
Run Code Online (Sandbox Code Playgroud)

我怎么能在让这个QueryExpression LinkQuery ConditionsFilters,也是我不想从开始因为一个可能的条件太多.

这是我到目前为止所尝试的

QueryExpression query = new QueryExpression("A");
            query.ColumnSet.AllColumns = true;
            var link = new LinkEntity() …
Run Code Online (Sandbox Code Playgroud)

crm dynamics-crm query-expressions xrm

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

不区分大小写的QueryExpression

是否可以使用不区分大小写的ConditionExpression构建查询?

ConditionExpression condition = new ConditionExpression() 
{ 
  AttributeName = "lastname", 
  Operator = ConditionOperator.BeginsWith, 
  Values = new ObservableCollection<object>() { searchName } 
};
Run Code Online (Sandbox Code Playgroud)

在这个例子中,我希望searchName的搜索不区分大小写.

c# case-insensitive dynamics-crm query-expressions dynamics-crm-2011

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

查询表达式与Lambda表达式

使用查询表达式而不是lambda表达式有什么意义?它不仅更慢,更冗长(见这里):

示例(来自上面的链接):

QE: var products = from p in northwind.Products where p.Category.CategoryName == "Beverages" select p;
LE: var products = northwind.Products.Where(p => p.Category.CategoryName == "Beverages");
Run Code Online (Sandbox Code Playgroud)

结果(来自上面的链接):

QE: 00:00:00.0019557, avg. 00:00:00.0004552
LE: 00:00:00.0000574, avg. 00:00:00.0000133
Run Code Online (Sandbox Code Playgroud)

为了便于阅读,是否真的值得将代码放慢34倍?

c# linq performance lambda query-expressions

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

如何在早期绑定状态码上为QueryExpression创建ConditionExpression?

在后期绑定我会使用这样的东西来添加一个只获得活动记录的条件.

new ConditionExpression
{
  AttributeName = "statecode",
  Operator = ConditionOperator.NotEqual,
  Values = { SomeClass.Active }
}
Run Code Online (Sandbox Code Playgroud)

但是我怎么在晚期表达呢?

另外,为什么MS要求将它转换为String而不是int

创建将属性值与枚举(例如状态代码)进行比较的条件时,必须使用ToString方法将值转换为字符串.

c# query-expressions dynamics-crm-2011

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

F#查询表达式:不能使用"for"!

无论出于何种原因,我都不能在查询表达式中使用"for"构造.我得到的是以下错误.代码我正是我以前选择的工作 - >"错误:只有在计算表达式构建器定义'For'方法时才可以使用此控件构造"

#r "System.Data.Linq.dll"
#r "FSharp.Data.TypeProviders.dll"

open FSharp.Linq
open FSharp.Data.TypeProviders

[<Literal>]
let connectionString' = @"
    data source = ...;
    initial catalog = NORTHWND;
    Integrated Security = SSPI"

type NorthwndDb =
    SqlDataConnection<connectionString', Pluralize = true>

let db' = NorthwndDb.GetDataContext()

let curstomerSortedByCountry =
    query { for c in db'.Customers do
                sortBy c.Country
                select (c.Country, c.CompanyName) } 
    |> Seq.cache
Run Code Online (Sandbox Code Playgroud)

f# for-loop query-expressions

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

MS Dynamics - QueryExpression 与 ConditionOperator.In 结果没有结果,但与 ConditionOperator.Equal 一起使用

我正在尝试进行查询以检索包含字符串列表中的文本之一的所有记录。

    QueryExpression query = new QueryExpression("account")
                {
                    ColumnSet = new ColumnSet("primarycontactid", "new_text"),
                    NoLock = true,
                    Criteria =
                    {
                        Conditions =
                        {
                            new ConditionExpression()
                            {
                                AttributeName = "new_text",
                                Operator = ConditionOperator.In,
                                Values = { texts.ToArray() }
                            }
                        }
                    }
                };
Run Code Online (Sandbox Code Playgroud)

此代码执行没有问题,但不返回任何记录。

我还尝试了以下代码,导致返回多条记录。

    QueryExpression query = new QueryExpression("account")
                {
                    ColumnSet = new ColumnSet("primarycontactid", "new_text"),
                    NoLock = true,
                    Criteria =
                    {
                        Conditions =
                        {
                            new ConditionExpression()
                            {
                                AttributeName = "new_text",
                                Operator = ConditionOperator.Equal,
                                Values = { texts.ToArray()[0] }
                            }
                        }
                    }
                };
Run Code Online (Sandbox Code Playgroud)

我也尝试过,没有错误,但没有返回。 …

c# microsoft-dynamics dynamics-crm query-expressions dynamics-365

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

CRM 2011 KeyNotFoundException异常

我是CRM开发的新手.我有一个自定义实体"客户".该实体有一个名为"defaultcustomer"的字段,可以是TRUE或FALSE.我正在使用插件,我需要为所有"客户"将"defaultcustomer"设置为FALSE.我这样做如下:

事实:

我已经为实体"客户"本身注册了插件.因此,当实体"客户"更新时,插件将触发.

private void MakeAllNonDefault()
{

    try
    {
        QueryExpression query = new QueryExpression("customer");
        query.ColumnSet = new ColumnSet("defaultcustomer");

        EntityCollection retrieved = service.RetrieveMultiple(query);

        foreach (Entity myCustomer in retrieved.Entities)
        {

            myCustomer["defaultcustomer"] = false;
            service.Update(myCustomer);
        }

    }
    catch (Exception ex)
    {
        throw new InvalidPluginExecutionException("An error occurred in MakeAllNonDefault(): " + ex.ToString());
    }
}
Run Code Online (Sandbox Code Playgroud)

错误: 它会在此行引发错误:

myCustomer["defaultcustomer"] = false;

System.Collections.Generic.KeyNotFoundException: 
The given key was not present in the dictionary. 
Run Code Online (Sandbox Code Playgroud)

keynotfoundexception query-expressions dynamics-crm-2011

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

为CRM 2011编写Native SQL

我想知道我可以编写本机SQL来添加或删除操作而不是使用Query Expression或FetchXML等.我知道Query Expression非常有用,但我真正关心的是性能,我认为编写SQL可能比其他更快.

crm dynamics-crm query-expressions fetchxml dynamics-crm-2011

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

如何在MS CRM查询表达式中添加选项集筛选条件?

我有一个实体LeaveType有两个属性,1.类型,2.可用天数,其中Type是一个选项集,Available days是一个文本字段.我想获取所有这些LeaveType记录,其中Type ='Annual'在选项集中选择.我无法找到如何为选项设置值添加过滤器查询表达式.以下是我的进度方法:

public Entity Getleavetype(Guid LeaveDetailsId, IOrganizationService _orgService, CodeActivityContext Acontext)
        {
            QueryExpression GetLeavedetails = new QueryExpression();
            GetLeavedetails.EntityName = "sgfdhr_leavetype";
            GetLeavedetails.ColumnSet = new ColumnSet("new_type");
            GetLeavedetails.ColumnSet = new ColumnSet("new_availabledays");
            GetLeavedetails.Criteria.AddCondition("new_type", ConditionOperator.Equal,   "Annual" ); //Is this correct????
            GetLeavedetails.Criteria.AddCondition("new_employeeleavecalculation", ConditionOperator.Equal, LeaveDetailsId); //ignore this

            //((OptionSetValue)LeaveDetailsId["new_leavetype"]).Value

            EntityCollection LeaveDetails = _orgService.RetrieveMultiple(GetLeavedetails);
            return LeaveDetails[0];
        }
Run Code Online (Sandbox Code Playgroud)

crm query-expressions dynamics-crm-2011

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