score:3
One common reason is that stored procedures have notoriously weak metadata, particularly for complex code with branches etc. It is very hard for the external code to really understand what is being selected/returned.
A common trick is to replace the sproc with something mind-numbingly simple (i.e. that simply returns any sample data of the desired schema) for the process of inspection, and then swap back to the real code. Alternatively, if possible consider swapping to a UDF - as UDFs have much stronger schema metadata.
Of course, you could also hand-edit the DBML based on something similar that works correctly.
As an aside - you may have a number of issues with that existing code, including (but not limited to) DML/DDL transitions (forces recompile), multiple updates to the same table (forces selective recompile) - not to mention the cursor usage (which may of may not be necessary). Table variables (@table rather than #table) may be useful too. I'm not offering to re-write it; just note some things you might want to look at.
score:-1
The first SELECT in your SPROC is yielding an INT into the temporary variable
SELECT @CONTRACT = CONTRACT FROM [tbl_property] WHERE [PROPREF] = @PROPREF
which is what is tripping up the metadata. You should do a
SET @CONTRACT = (SELECT CONTRACT FROM [tbl_property] WHERE [PROPREF] = @PROPREF)
instead.
Source: stackoverflow.com
Related Articles
- Stored Procedure returning an int
- Linq Stored Procedure Issue- Returning an int
- Stored Procedure has void type instead of returning my desired result
- returning byte array from stored procedure using linq to sql
- Returning values from a stored procedure
- Returning single value from SQL Stored Procedure using LINQ
- Linq statement with stored procedure returning column value
- Stored procedure with static data not returning values
- Code First calling a stored procedure passing in 3 params validation errors
- Map extra column from stored procedure to Entity Framework code first model
- Executing a Stored Procedure from EntityFramework - Code First
- Reuse stored procedure result in linq to sql in Code First
- Is it Possible to call a Stored Procedure using LINQ in LINQPad?
- Do I need to SubmitChanges after executing a stored procedure with Linq-To-Sql?
- Stored Procedure return values with linq data context
- Rollback a stored procedure call from inside a transaction using LINQ-to-SQL?
- Getting stored procedure output parameter with LINQ and Entity Framework
- How to execute stored procedure and get return result in MVC/EF/LINQ
- LINQ calling a Stored Procedure is slow
- How to create a complex type from a stored procedure that uses exec()?
- LINQ on a DataTable IN a CLR Stored Procedure
- Paging in the stored procedure
- Creating objects from stored procedure result
- Lost decimal precision and scale using LINQ and stored procedure with output parameters
- Linq Stored Procedure Timeout but SSMS Quick
- Linq - interrupt execution of stored procedure
- Execute stored procedure using entity framework
- LINQ to SQL: Stored Procedure Results
- Linq stored procedure to return XML
- How to use a stored procedure in ADO.NET Entity Framework
- Yield return IEnumerable<IEnumerable<...>>
- Error: The type or namespace name 'ExcelPackage' could not be found
- How to fetch attribute value under elements/elements in xml using LINQ
- Linq Join hierarchy (one to many)
- how to use an expression in a select clause
- Get a list of clubs that have a person as member
- c# can I type the code I want to execute in LINQ expressions
- linq: Get Max value, then get an associated property of that result
- convert Dictionary<string, myClass> to List<double[]> using c# linq
- Filtering rows of a DataTable with the return type of a DataTable
- Calling a custom method in LINQ query
- Linq joins throwing exception
- how can combine multi table with same columns in one common view model
- LEFT JOIN linq to sql
- Combining DataTables obtained from DataSet.ReadXML
- Linq query for list of strings assign to ViewModel in C#.net?
- Expression with parameter (LINQ, SQL,C#)
- How to convert a string in lambda to decimal?
- using an Array type as a Parameter Expression
- Select two columns of similar types in a Linq Query