tags:

views:

39

answers:

1

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 linq 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.

+1  A: 

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.

Justin Niessner
because i can't drop the sp onto the correct table I think it's not configuring the IntelliSense. I've deleted and readded to make sure, still the same issue.
Rob
oops, quite write. I changed the sp to retireve data from a view and not the original table.
Rob