Solved

Linq to sql , dbml - query

Posted on 2010-09-16
3
872 Views
Last Modified: 2013-11-11
Is it possible to write sql query inside the dbml context like we could do in the datasets wizards in the ado.net.
Or should the query be written only in the asp.net code?

any suggestions ould be great. thanks
0
Comment
Question by:TrialUser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
james-ct16 earned 250 total points
ID: 33691588
Howdy

The code should be written in linq. Remember the linq to sql translates the linq query to sql so you dont get all the data and parse it again. If you want to check this run the database profilers and look at the code generated.

Scott Guhrie gives a good worked example of this at http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx

Hope that Helps

James
0
 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
ID: 33692569
Hi TrialUser;

Although you can not write an sql query inside the dbml context you can execute a SQL query from inside your code by using the DataContext method ExecuteCommand the syntax is :

public int ExecuteCommand( string command, params Object[] parameters )

Documentation here
http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.executecommand.aspx

Fernando
0
 

Author Closing Comment

by:TrialUser
ID: 33795004
thanks
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question