Created
March 15, 2012 22:22
-
-
Save jferguson/2047357 to your computer and use it in GitHub Desktop.
Query an EF View with SqlQuery<T>
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
[TestFixture] | |
public class QuerySomeView | |
{ | |
[Test] | |
public void DoIt() | |
{ | |
var context = new StoreContext(); | |
var results = context.Database.SqlQuery<ReadModel>("SELECT * FROM SomeView").ToList(); | |
Assert.AreEqual(results.Count(), 2); | |
} | |
public class ReadModel | |
{ | |
public string Name { get; set; } | |
public string Code { get; set; } | |
public string Phone { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment