Telerik OpenAccess e più condizioni nella clausola where
-
08-07-2019 - |
Domanda
Ho appena scritto alcuni test unitari e con mio orrore è fallito.
Ecco il mio 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);
}
}
mi sta dando la seguente eccezione, Impossibile lanciare un oggetto di tipo 'Entities.Testing.TempClient' per digitare 'System.String'. È normale, spero di no, il seguente test funziona correttamente. Immagino che ci sia un problema nell'analisi dell'espressione ... Sarà risolto?
[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);
}
}
Soluzione
Dopo aver contattato l'assistenza di Telerik, non è stato possibile.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow