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

时间:2021-04-24 23:09:32

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'. 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?

它给了我以下异常,无法将类型为'Entities.Testing.TempClient'的对象强制转换为'System.String'。这是正常的,我希望不是,以下测试正常。我猜解析表达式时有问题...这会被解决吗?

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

1 个解决方案

#1


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

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

#1


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

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