I am not sure how I reference the database and the database table through LINQ. I put it as Database.databaseTableName in the code below. I want to return as a JsonResult. I can do this if I were using a class that inherits from DbContext by using ado.net entity model, but I'm not using that.
public JsonResult getInfo()
{
try
{
string connectionString = "Data Source = thispartWorks; Initial Catalog = serverName; Persist Security Info = True; User ID = id; Password = pw";
conn = new SqlConnection(connectionString);
conn.Open();
var query = (from bob in Database.databaseTableName
orderby bob.ReceivedDate descending
select bob).Take(1000);
return new JsonResult { Data = query, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
finally
{
conn.Close();
}
}