Answered linq to sql use real sql scripts?

  • Saturday, September 15, 2012 6:35 AM
     
     

     In a C# 2010 desktop/console application, I am currently using linq to sql to connect to a sql server 2008 database. So far in this application, I have used straight linq to connect to the database.   However now I need to obtain data from various tables so that the data can be setup for a new user to access the data.

    The database people at my job say it is easier to write the logic using a sql script they can give me.

     Thus my question is, can linq to sql use 'stright sql' somehow? Basically can I have linq to sql use a stored procedure? If so, can you tell me and/or point me to a reference that will show me how linq to sql can use a stored procedure?

All Replies

  • Saturday, September 15, 2012 3:52 PM
     
     Answered
    Hi midnight_car;

    To your question, "can linq to sql use 'stright sql' somehow?", yes it can be used with stored procedure As well as executing T-SQL directly from you program. See this article LINQ to SQL (Part 6 - Retrieving Data Using Stored Procedures) and to execute directly from code look at the DataContext Class ExecuteXXX methods.

      

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked As Answer by midnight_car Sunday, September 16, 2012 11:22 PM
    •  
  • Saturday, September 15, 2012 8:15 PM
     
     
    Thanks!
    • Edited by midnight_car Sunday, September 16, 2012 11:22 PM
    •  
  • Monday, September 17, 2012 3:10 AM
     
     
      

    Not a problem, glad I was able to help.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".