I have an endless problem with trying to call a stored procedure from a controller - if I could add generosity to this, as it took too much time, and I don't know what else (but I have no points). Based on my research, it seems like this is a known bug, but not workarounds worked for me, so I will do my best to explain in the hope of a solution:
1- I am creating a stored procedure that looks something like this:
CREATE PROCEDURE [dbo].[db_name]
@start_dt datetime,
@end_dt datetime
AS
BEGIN
SET FMTONLY OFF;
SELECT [date],
COUNT(visits) as Visits,
SUM(CASE entrance WHEN '1' THEN 1 ELSE 0 END) AS ENT1,
SUM(CASE entrance WHEN '2' THEN 1 ELSE 0 END) AS ENT2,
SUM(CASE entrance WHEN '3' THEN 1 ELSE 0 END) AS ENT3,
SUM(CASE entrance WHEN '4' THEN 1 ELSE 0 END) AS ENT4,
SUM(CASE entrance WHEN '5' THEN 1 ELSE 0 END) AS ENT5
FROM some_view
WHERE [date] between @start_dt and @end_dt
group by [date]
END
2 - Then I created the LINQ to SQL object object manually, which has a property for each of the above columns (Date, Visits, ENT1, ENT2 ... ENT5).
3 - proc VS, , , " ". ( , , . ).
** . , Visual Studio , Int - . ** , , select ,
4 - , , , IMultipleResults - .
, , int.
! MVC, , , , , , .
UPDATE, XML :
<?xml version="1.0" encoding="utf-8"?>
<Database Name="DB_Name" Class="nameDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Connection Mode="WebSettings" ConnectionString="Data Source=some_data_source;Initial Catalog=some_db;Integrated Security=True" SettingsObjectName="System.Configuration.ConfigurationManager.ConnectionStrings" SettingsPropertyName="name_ConnectionString" Provider="System.Data.SqlClient" />
<Table Name="" Member="Visits">
<Type Name="Visit">
<Column Name="Date" Type="System.DateTime" CanBeNull="false" />
<Column Name="Visits" Type="System.Int32" CanBeNull="false" />
<Column Name="ENT1" Type="System.Int32" CanBeNull="false" />
<Column Name="ENT2" Type="System.Int32" CanBeNull="false" />
<Column Name="ENT3" Type="System.Int32" CanBeNull="false" />
<Column Name="ENT4" Type="System.Int32" CanBeNull="false" />
<Column Name="ENT5" Type="System.Int32" CanBeNull="false" />
</Type>
</Table>
<Function Name="dbo.sp_proc_name" Method="sp_proc_name">
<Parameter Name="start_dt" Type="System.DateTime" DbType="DateTime" />
<Parameter Name="end_dt" Type="System.DateTime" DbType="DateTime" />
<ElementType Name="sp_proc_nameResult">
<Column Name="date" Type="System.String" DbType="VarChar(30)" CanBeNull="true" />
<Column Name="Visits" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="ENT1" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="ENT2" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="ENT3" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="ENT4" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="ENT5" Type="System.Int32" DbType="Int" CanBeNull="true" />
</ElementType>
</Function>
</Database>
2
Visual studio, , :
No rows affected.
(129 row(s) returned)
@RETURN_VALUE = 0
, , , , .