Telerik OpenAccess 和 where 子句中的多个条件 [英] Telerik OpenAccess and multiple conditions in the where clause

查看:76
本文介绍了Telerik OpenAccess 和 where 子句中的多个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚编写了一些单元测试,但令我震惊的是它失败了.

I have just written a few unit tests and to my horror it failed.

这是我的测试...

[TestMethod]
public void FetchWithMoreThanOneConditionUsingKnownTypes() 
{
  using (var scope = EntityObjectScopeProvider.GetNewObjectScope()) 
  {
    var temp = new TempClient() { FirstName = "Rohan", Surname = "West" }; 
    var entity = scope.Extent<ClientEntity>().Where(c => temp.FirstName == c.FirstName && temp.Surname == c.Surname).FirstOrDefault(); 

    Assert.IsNotNull(entity);
    Assert.AreEqual(entity.FirstName, temp.FirstName); 
    Assert.AreEqual(entity.Surname, temp.Surname); 
  }
}

它给了我以下异常,无法将Entities.Testing.TempClient"类型的对象转换为System.String".这是否正常,我希望不是,以下测试正常工作.估计是在解析表达式的时候有问题...会解决这个问题吗?

it is giving me the following exception, Unable to cast object of type 'Entities.Testing.TempClient' to type 'System.String'. Is this normal, i hope not, The following test works correctly. I guess there is a problem when parsing the expression... Will this be fixed?

[TestMethod]
public void FetchWithMoreThanOneConditionUsingTempVariables() 
{
  using (var scope = EntityObjectScopeProvider.GetNewObjectScope()) 
  {
    var temp = new TempClient(){ FirstName = "Rohan", Surname = "West" };   

    string firstname = temp.FirstName; 
    string surname = temp.Surname; 

    var entity = scope.Extent<ClientEntity>().Where(c => c.FirstName == firstname && c.Surname == surname).FirstOrDefault(); 

    Assert.IsNotNull(entity);
    Assert.AreEqual(entity.FirstName, temp.FirstName);
    Assert.AreEqual(entity.Surname, temp.Surname); 
  }
}

推荐答案

在联系 Telerik 支持后,结果证明这是不可能的.

After contacting Telerik support, it turned out not to be possible.

这篇关于Telerik OpenAccess 和 where 子句中的多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆