Last active
December 14, 2016 16:00
-
-
Save Kayli/fc1679abc667390e2d7c3cad74d49cf5 to your computer and use it in GitHub Desktop.
database query using EF
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
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<connectionStrings> | |
<add name="Default" connectionString="Server=localhost;Database=RegoV2;Persist Security Info=True;integrated security=false;User Id=sa; Password=sa;" providerName="System.Data.SqlClient" /> | |
</connectionStrings> | |
</configuration> |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var context = new DbContext(ConfigurationManager.ConnectionStrings["Default"].ConnectionString); | |
var records = context.Database.SqlQuery<SomeTableRecord>("select Id, Name from SomeTable").ToArray(); | |
} | |
} | |
class SomeTableRecord | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment