I Have a requirement where i need to pass only sql select statement as a parameter to Service. Instead of writing query in the service i need to accept the query as a parameter.
Any suggestions, samples or links would be appreciated.
Thanks
I Have a requirement where i need to pass only sql select statement as a parameter to Service. Instead of writing query in the service i need to accept the query as a parameter.
Any suggestions, samples or links would be appreciated.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mahesh ChandRank #1 · 393.3K reputationPosted Mar 29, 2009, 6:09 AM EDT
mohammed irfan45 reputationPosted Mar 29, 2009, 11:42 AM EDT
Hello Mr Mahesh Chand,
Glad to see responce from you, however the issue might be very simple, i tried a lot searching on the net but found no relevant solution to the issue.
Please if you can help me out.
The issue:
Generally iam using List class in web service and 'LINQ to SQL' with tables from database to fetch the data.
For example iam having a .dbml file with 'Empinfo' table.
and in the Service iam having
public List<EmpInfo> GetEmpinfo()
{
DataClassesDataContext db = new DataClassesDataContext();
var mEmp = from empinfo in db.EmpInfos
select empinfo;
return mEmp.ToList();
}
and iam filling the datagrid in page.xaml.cs with the result as
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
ServiceReference1.DServiceClient webService = new ServiceReference1.DServiceClient();
webService.GetEmpinfoCompleted += new EventHandlerGetEmpinfoCompletedEventArgs >(webService_ GetEmpinfoCompleted);
webService.GetEmpinfoAsync();
}
void webService_GetEmpinfoCompleted (Object sender, ServiceReference1.GetEmpinfoCompletedEventArgs e)
{
DataGrid1.ItemsSource = e.Result;
}
My concern is to pass an sql query as string parameter to query one or more tables in database, but not use a specific query to a specific table(s),
How do i use sql select statement based on one or more tables which are not there in LINQ to SQL.
For this purpose i used Stored procedure with query as parameter in LINQ to SQL but it did not work.
also i tried to use dataset in Service but end up with error.
Please if any one can help me with some hints, samples or references.
Thank you all.