Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Function import in dynamic store procedure

$
0
0

I have a store procedure with dynamic query. I am passing the column name in a variable and getting the result. Here is the store procedure.

ALTER PROCEDURE [dbo].[prosperGetSampleResults]
	@TestId varchar(200),
	@TestSeriesId varchar(200),
	@ColName varchar(128)
AS

if @TestId is null
begin
  set @TestId = 73
end

if @TestSeriesId is null
begin
  set @TestId = 1005
end

if @ColName is null
begin
  set @ColName = 'Gloss60'
end

BEGIN
	DECLARE @FMTONLY BIT;
	 IF 1 = 0
	 BEGIN
	  SET @FMTONLY = 1;
	  SET FMTONLY OFF;
	 END

	SET NOCOUNT ON;
	declare @sql nvarchar(max)
 select @sql = 'SELECT T.TestSeriesSampleId
 ,SS.TestSeriesId,T.TestId,SS.TestSeriesSampleCode,S.TestDescription,T.[Standard],R.ExposureTime,R.TotalExposureTime,R.' + @ColName+'
  as Result from TestSeriesSampleTesting T

 inner join TestSeriesSampleResults R
 on T.TestSeriesSampleId = R.TestSeriesSampleId

 inner join TestSeriesSample SS
 on SS.TestSeriesSampleId = T.TestSeriesSampleId

 inner join Test S
 on S.TestId = T.TestId and T.TestId = ' +@TestId+'
 and SS.TestSeriesId = '+ @TestSeriesId

	SET FMTONLY OFF;

  exec sp_executesql @sql

  IF @FMTONLY = 1
  BEGIN
  SET FMTONLY ON;
 END

END

 

Now in entity framework when I am trying to add function import, the complex query is disabled and no result is coming clicking on 'Get Column Information' button. Please help how to solve the problem. 


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>