Created
September 28, 2014 11:55
-
-
Save ahmad2x4/ae925ff32eeec9685cf1 to your computer and use it in GitHub Desktop.
blog Automapper extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
[UseDatabase] | |
public void ShouldConvertPredicates() | |
{ | |
var connStr = ConfigurationManager.ConnectionStrings["SQLExpressConnection"].ConnectionString; | |
var myContext = new MyContext(connStr); | |
using (var repository = new SourceRepositorySql(myContext)) | |
{ | |
AddRecords(repository); | |
myContext.SaveChanges(); | |
const string name = "Ahmadreza"; | |
var query = repository.Find(s => s.FullName == name && s.NumberOfYears > 10); | |
var result = query.Project().To<Source>().ToList(); | |
Assert.Equal(1, result.Count); | |
Assert.Equal(name, result.First().FullName); | |
} | |
} | |
private static void AddRecords(IRepository<Source, Destination> repository) | |
{ | |
repository.Add(new Source { FullName = "Ahmadreza", NumberOfYears = 35 }); | |
repository.Add(new Source { FullName = "Ahmadreza", NumberOfYears = 9 }); | |
repository.Add(new Source { FullName = "Jon", NumberOfYears = 20 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment