sql server - EF4 - The selected stored procedure returns no columns -


i have query in stored procedure calls linked servers dynamic sql. understand ef doesn't that, listed columns returned. yet, still doesn't that. doing wrong here? want ef able detect columns returned stored procedure can create classes need.

please see following code makes last lines of stored procedure:

select     #tempmain.id,     #tempmain.class_data,     #tempmain.web_store_class1,     #tempmain.web_store_class2,     #tempmain.web_store_status,     #tempmain.cur_1pc_cat51_price,     #tempmain.cur_1pc_cat52_price,     #tempmain.cur_1pc_cat61_price,     #tempmain.cur_1pc_cat62_price,     #tempmain.cur_1pc_cat63_price,     #tempmain.flat_length,     #tempmain.flat_width,     #tempmain.item_height,     #tempmain.item_weight,     #tempmain.um,     #tempmain.lead_time_code,     #tempmain.wp_image_nme,     #tempmain.wp_mod_dte,     #tempmain.catalog_price_chg_dt,     #tempmain.description,     #tempmain.supersede_ctl,     #tempmain.supersede_pn,     tempdesc.cust_desc,     tempmfgr.mfgr_item_nbr,     tempmfgr.mfgr_name,     tempmfgr.vendor_id     #tempmain         left join tempdesc on #tempmain.id = tempdesc.id         left join tempmfgr on #tempmain.id = tempmfgr.id 

ef doesn't support importing stored procedures build result set from:

  • dynamic queries
  • temporary tables

the reason import procedure ef must execute it. such operation can dangerous because can trigger changes in database. because of ef uses special sql command before executes stored procedure:

set fmtonly on 

by executing command stored procedure return "metadata" columns in result set , not execute logic. because logic wasn't executed there no temporary table (or built dynamic query) metadata contains nothing.

you have 2 choices (except 1 requires re-writing stored procedure not use these features):

  • define returned complex type manually (i guess should work)
  • use hack , adding stored procedure put @ beginning set fmtonly off. allow rest of sp's code execute in normal way. make sure sp doesn't modify data because these modifications executed during import! after successful import remove hack.

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -