开发者

Group By store procedure with Linq to Sql

I have this store procedure...

select 
    a.IsDirectClient
from 
    dbo.Companies as a 
where a.SchemeName = @SchemeName
    group by a.IsDirectClient

which I'd like to use in my solution via l开发者_如何学JAVAinq and a data context. However I can't drop this store procedure onto the company table because I get the "... database objects return a schema that does not match the schema of the target data class..." error. (is this because it's returning a single field instead of "*" ?)

my question is how do I use this store procedure with linq, I can use the var object:

var directclient = db.DirectClientForScheme("xxx");

but then I don't have access to the 'IsDirectClient' property through intellisense.


LINQ to SQL will automatically generate a type to handle the return value of each of your stored procedures (unless otherwise specified in the options).

Using var directclient = ... shouldn't give you any issues with IntelliSense though, which tells me there's a bigger problem.

Has the Stored Procedure changed since you generated your LINQ to SQL classes? Even if you don't think so, try refreshing the stored procedure in you LINQ to SQL diagram and see if the auto-generated return type gets properly generated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜