简体   繁体   English

Telerik OpenAccess和where子句中的多个条件

[英]Telerik OpenAccess and multiple conditions in the where clause

I have just written a few unit tests and to my horror it failed. 我刚刚编写了一些单元测试,但令我恐惧的是它失败了。

Here is my test... 这是我的测试...

[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); 
  }
}

it is giving me the following exception, Unable to cast object of type 'Entities.Testing.TempClient' to type 'System.String'. 它给了我以下异常,无法将类型为“ Entities.Testing.TempClient”的对象转换为类型为“ 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支持人员后,事实证明这是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM