472,373 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

Linq: #Temp tables in SPROCS do not have return values in generatedmethods

Hi everyone,

I have a SPROC which selects records into a MSSQL #temp table and then
selects the records from that. I drag this SPROC onto the right-hand
pane of the DBML diagram, but the method that gets generated for the
SPROC does not have a return type. Any ideas why this is?

I am referring to Scott Guthrie's blog article here:

http://weblogs.asp.net/scottgu/archi...rocedures.aspx
Dec 4 '07 #1
4 2272
I have checked, and yes - this appears to be the case even for simple
cases.
I would guess that this is because the metadata for temp-tables is *in
the general case* too weak (since the table could be external to the
SP, or could have multiple create points [either of which would also
cause constant SP recompiles]).

If your data-volumes aren't immense, and you don't use an index on the
temp-table, then perhaps consider using a table-variable instead [
DECLARE @varname TABLE (...) ]; the metadata is much stronger and it
works as expected.

If table-variables aren't an option, then you can also edit the dbml
directly: right-click; Open With...; XML Editor; locate your SP and
replace e.g.
<Return Type="System.Int32" />
with
<ElementType Name="StoredProcedure2Result"><!-- bad name ;-p -->
<Column Name="ID" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false" />
<Column Name="Value" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false" />
</ElementType>
and rebuild.

Note that there is also a LINQ-specific forum that you may find
useful:

http://forums.microsoft.com/MSDN/Sho...D=123&SiteID=1

Marc
Dec 4 '07 #2
Marc Gravell wrote:
I have checked, and yes - this appears to be the case even for simple
cases. I would guess that this is because the metadata for
temp-tables is *in the general case* too weak (since the table could
be external to the SP, or could have multiple create points [either
of which would also cause constant SP recompiles]).

If your data-volumes aren't immense, and you don't use an index on
the temp-table, then perhaps consider using a table-variable instead
[ DECLARE @varname TABLE (...) ]; the metadata is much stronger and
it works as expected.

If table-variables aren't an option, then you can also edit the dbml
directly: right-click; Open With...; XML Editor; locate your SP and
replace e.g. <Return Type="System.Int32" /with
<ElementType Name="StoredProcedure2Result"><!-- bad name ;-p -->
<Column Name="ID" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false" / <Column Name="Value" Type="System.Int32"
DbType="Int NOT NULL" CanBeNull="false" / </ElementType>
and rebuild.

Note that there is also a LINQ-specific forum that you may find
useful:

http://forums.microsoft.com/MSDN/Sho...D=123&SiteID=1

Marc
It's due to an issue in sqlserver. See my reply in the adonet
newsgroup on this server.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Dec 4 '07 #3
Hi Marc

Thanks for your insightful reply. Great tip on editing the dbml file,
wasn't aware that you could directly edit it. I did use a @temp table
variable and it worked. However after binding to the grid directly I
had trouble sorting and paging. I also could not bind the method to an
ObjectDataSource and from memory the error given was 'This method(?)
does not support server side paging(?)' or something along those
lines. Anyway ended up reverting to good old a DataSet and an
ObjectDataSource for binding to my ASP.NET GridView :)

On Dec 4, 6:35 pm, "Marc Gravell" <marc.grav...@gmail.comwrote:
I have checked, and yes - this appears to be the case even for simple
cases.
I would guess that this is because the metadata for temp-tables is *in
the general case* too weak (since the table could be external to the
SP, or could have multiple create points [either of which would also
cause constant SP recompiles]).

If your data-volumes aren't immense, and you don't use an index on the
temp-table, then perhaps consider using a table-variable instead [
DECLARE @varname TABLE (...) ]; the metadata is much stronger and it
works as expected.

If table-variables aren't an option, then you can also edit the dbml
directly: right-click; Open With...; XML Editor; locate your SP and
replace e.g.
<Return Type="System.Int32" />
with
<ElementType Name="StoredProcedure2Result"><!-- bad name ;-p -->
<Column Name="ID" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false" />
<Column Name="Value" Type="System.Int32" DbType="Int NOT NULL"
CanBeNull="false" />
</ElementType>
and rebuild.

Note that there is also a LINQ-specific forum that you may find
useful:

http://forums.microsoft.com/MSDN/Sho...D=123&SiteID=1

Marc
Dec 7 '07 #4
Fair enough; the paging etc probably would have been solvable, but
obviously it isn't going to be able to inject sort/page code directly
into an SP. But if you're happy...

Marc
Dec 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Oksana Yasynska | last post by:
Hi all, I'm running Postgres 7.2.1 and I need to return multiple row sets from plpgsql function. I'm new in plpgsql but according documentation and everything I could find in the mailing list...
21
by: Boris Popov | last post by:
Hello pgsql-general, I'm trying to implement a table with rows that are automatically deleted when the session that inserted them disconnects, sort of like our own alternative to...
2
by: shapper | last post by:
Hello, I created 3 few tables that have Many to Many relationships: Posts (PostId PK) Files (FileId PK) PostsTags (PostId PK, TagId PK) FilesTags (FileId PK, TagId PK)
14
by: Ralf Rottmann \(www.24100.net\) | last post by:
I recently stumbled across a pretty interesting LINQ to SQL question and wonder, whether anybody might have an answer. (I'm doing quite some increasing LINQ evangelism down here in Germany.). ...
1
by: Esteban404 | last post by:
//using C# 2005, MS SQL 2000(prod) and SQL Express 2005 (dev) My sprocs all have a clearing mechanism at the end like this for each temporary table I use: --drop temporary tables IF...
1
by: john | last post by:
LINQ works a lot like an Access DB Recordset in the way it functions, one of the things I could do in Access is refer to the Fields thru a Variable as below allowing me to Iterate over the...
6
by: Iaml | last post by:
I have an XML file and the depth of each node is unpredictable. I need to find the parent node which contains an element whose certain attribute has the given value. Then I will process that...
13
by: Dan Tallent | last post by:
I have a query which I would like to convert to LINQ. I am having problems finding good examples or references that cover more complex queries. Here is the SQL command I would like to rewrite...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.