Skip to content

Instantly share code, notes, and snippets.

@jferguson
Created March 15, 2012 22:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jferguson/2047357 to your computer and use it in GitHub Desktop.
Save jferguson/2047357 to your computer and use it in GitHub Desktop.
Query an EF View with SqlQuery<T>
[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