0

New to EF... using 6.0. I've have a Stored Proc which has the dynamic build select query inside a string variable that outputs using Execute(@StringQuery). This select has around 20 columns.

After adding this SP in EF, the return type is INT (not sure why). But I think I've to add all the columns manually in Complex types in EDMX. Wanted to know whether there is any better way to handle this as the columns are in huge number.

Please suggest.

Procedure Text:

DECLARE @StringQuery VARCHAR(MAX)
SET @StringQuery = 'SELECT AROUND 20 COLUMNS WITH LOT OF CONDITIONS ADDED'

EXECUTE(@StringQuery)

1 Answer 1

1
  1. Open your model
  2. Go to View->Other Windows->Entity Data Model Browser
  3. In browser expand your Model->Function Imports and double click on Stored Proc
  4. In Returns a Collections off choose Complex and press Get Column Information
  5. Click Create New Complex Type
  6. OK, Save
Sign up to request clarification or add additional context in comments.

5 Comments

When I do that, I get message saying 'The selected stored procedure or function returns no columns' and OK button is disabled.
Can you paste you Procedure text?
I've added a sample of procedure how it looks like
Do you have logic in Storec proc which builds dynamic query? Try at top of your procedyre SET FMTONLY OFF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.