Friday, November 7, 2014

Execute Select statement in MVC

LINQ to SQL translates the queries you write into parameterized SQL queries (in text form) and sends them to the SQL server for processing. In cases where a LINQ to SQL query is insufficient for a specialized task, you can use the ExecuteQuery method to execute a SQL query, and then convert the result of your query directly into objects
// pushPinenitties linq to sql class added to model
// PushPinModel is model mapped to the query

public ActionResult GetData()
        {

           
            IEnumerable<PushPinModel> results = pushPinenitties.ExecuteQuery<PushPinModel>("SELECT latittude,longitude,title FROM loaction );
            //get loaction or latitude longitude according to databases            
          
            return View(results);
        }
So ExecuteQuery method direct execute the query

No comments:

Post a Comment

http://blogsiteslist.com