You have the method DataTable.Rows.Count
Why do not use it?
Here I am going to explain scenario's
from the following scenarios i written two procedures. I don't prefer out parameter and
return keyword. So how linq will support to get scalar values from below stored procs.
scenerio 1 :
create procedure Getvalue
as
select count(*) from emp
scenerio 2 :
create procedure GetCountValues
as
select count(*) from emp
select count(*) from dept
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi kravindra;
Be aware that the following is using Linq to SQL and the database must be a MS SQL server, Linq to SQL does not support any other type of database.
Because you do not want to use the OUT parameter the results of the queries will return a result set and not an integer. It seems to me that the environment may have some issues with the stored procedure if the Count(*) does not have a column name. So give them names as follows:
scenario 1 :
create procedure Getvalue
as
select count(*) AS EmpCount from emp
scenario 2 :
create procedure GetCountValues
as
select count(*) AS EmpCount from emp
select count(*) AS DeptCount from dept
Scenario 1 :
YourDataContext db = new YourDataContext();
int? gv = db.Getvalue().FirstOrDefau
Console.WriteLine(gv);
Scenario 2 :
This scenario is not as easy as the first one. The reason is that currently the DBML designer does not support the return of multiple result sets so you need to do a couple of extra things.
1. Right click on the design surface of the DBML designer and select "View Code"
2. Step one created a new file with a partial class of the data context, fill it as follows
using System.Data.Linq.Mapping;
using System.Data.Linq;
using System.Reflection;
namespace // Your namespace as stubbed out
{
partial class YourDataContext
{
// Define the return of the function
[Function(Name = "GetCountValues")]
[ResultType(typeof(emp))]
[ResultType(typeof(dept))]
public IMultipleResults GetCountValuesMR()
{
IExecuteResult result = this.ExecuteMethodCall(thi
((MethodInfo)(MethodInfo.G
return ((IMultipleResults)(result
}
}
}
3. Then in your code you can retrieve the two values as follows.
NorthwindDataContext db = new NorthwindDataContext();
int gcv1 = 0;
int gcv2 = 0;
// Execute the procedure and get the results
using (IMultipleResults results = db.GetCountValuesMR())
{
gcv1 = results.GetResult<int>().Ele
gcv2 = results.GetResult<int>().Ele
}
Console.WriteLine("Employe
Fernando
Business Accounts
Answer for Membership
by: JonthemoonPosted on 2009-11-06 at 08:27:26ID: 25760533
How do you call your query? To you use Visual Studio? C#?