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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
mohammed irfanPosted Mar 29, 2009, 3:42 PM
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.
Mahesh ChandPosted Mar 29, 2009, 10:09 AM