Solved

Linq to sql , dbml - query

Posted on 2010-09-16
3
871 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

740 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