Sorry but I dont understand
I have no error from code !!!
my stored procedure is as
CREATE PROCEDURE [dbo].[PivotOrdiniMeseLineaSp]
@Codage VARCHAR(3),
@CodiceCliente VARCHAR(5),
@Anno smallint,
@Linea VARCHAR(MAX)
AS
SELECT ...
FROM
(
SELECT ...
FROM ...
WHERE (dbo.tab.Codage = @Codage) AND
(dbo.tab.Anno = COALESCE(@Anno, dbo.tab.RolAnno) ) AND
(dbo.tab.Codcli = COALESCE(@CodiceCliente, dbo.tab.Codcli) ) AND
(CASE ... END IN ( SELECT Value FROM dbo.Split(COALESCE(@Linea,
CASE... END), ',')) )
)TAB
PIVOT (
SUM(Importo) FOR Mese IN ( [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12])
) PTab
---split function
CREATE FUNCTION [dbo].[Split]
(
@List nvarchar(2000),
@SplitOn nvarchar(5)
)
RETURNS @RtnValue table
(
Id int identity(1,1),
Value nvarchar(100)
)
AS
BEGIN
While (Charindex(@SplitOn,@List)>0)
Begin
Insert Into @RtnValue (value)
Select
Value = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1)))
Set @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End
Insert Into @RtnValue (Value)
Select Value = ltrim(rtrim(@List))
Return
END
When I pass @Linea parameter i receive no result i do that here
model = db.Database.
SqlQuery<OrdineMeseLineaView>("dbo.PivotOrdiniMeseLineaSp @p0, @p1,@p2, @p3",
Codage,
(object)cliente ?? DBNull.Value,
(object)anno ?? DBNull.Value,
(object)lineeSelezionate ?? DBNull.Value).ToList();
For now i solved passing null to @Linea
then I filter the model with join to selected lines (checkboxes)
model = from i in model
join x in lineeSelezionate on i.Linea equals x
select i;
model = db.Database.
SqlQuery<OrdineMeseLineaView>("dbo.PivotOrdiniMeseLineaSp @p0, @p1,@p2, @p3",
Codage,
(object)cliente ?? DBNull.Value,
(object)anno ?? DBNull.Value,
DBNull.Value).ToList();
But i would like a better solution