I have some legacy code with linq2sql classes. DataContext class has following definition for stored procedure:
[Function(Name="dbo.sp_Goods_SelectBySection")]
public ISingleResult<sp_Goods_SelectBySectionResult> sp_Goods_SelectBySection([Parameter(Name="SectionId", DbType="Int")] System.Nullable<int> sectionId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), sectionId);
return ((ISingleResult<sp_Goods_SelectBySectionResult>)(result.ReturnValue));
}
But when i am trying create same procedure in my own project, designer creating procedure with different implementation:
[Function(Name="dbo.sp_Goods_SelectBySection")]
public int sp_Goods_SelectBySection([Parameter(Name="SectionId", DbType="Int")] System.Nullable<int> sectionId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), sectionId);
return ((int)(result.ReturnValue));
}
And i cannt change type in method properties.
Here is code of stored procedure.
ALTER PROCEDURE [dbo].[sp_Goods_SelectBySection]
(
@SectionId INT
)
AS
BEGIN
SET NOCOUNT ON;
SELECT
Goods.Id,
Goods.[Name],
TypeId,
Makerid,
Price,
[Description],
Term,
Types.Name AS TypeName,
Makers.Name AS MakerName,
GoodsImage.SmallImageUrl AS MainImageUrl,
Goods.IsDeleted,
Goods.Rang
FROM Goods
INNER JOIN Types ON (Types.Id = Goods.TypeId)
INNER JOIN Makers ON (Makers.Id = Goods.MakerId)
LEFT JOIN GoodsImage ON ( GoodsImage.GoodId = Goods.Id AND GoodsImage.IsMain = 1 AND GoodsImage.IsDeleted = 0 )
WHERE
Types.SectionId = @SectionId
AND Goods.IsDeleted = 0
ORDER BY Rang ASC
END
Why? And how i can create procedure which returning ISingleResult instead of int?
Note i have many such procedures and modify by hand each of them is not good idea i think.
I guess it's designer problem. Because i created new test project and it work ok. Thanks to all who helped me. Especially to Andras Zoltan.