Click here to Skip to main content
14,114,975 members
Rate this:
 
Please Sign up or sign in to vote.
Hi,

i have created the stored procedure which returns data from multiple tables.

Here i i am unable(don't know) to call the stored procedure with parameter.

Can anyone please help me to resolve this.

I tried with one scenario its returns

Id = 18, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"


What I have tried:

created the console application.
1.created the models for all tables. stored procedures i cant.

2. Program.cs
-------------
var test = context.GetmessageAsync(int productId)


2. DBContext File
-----------------
public async Task<List<Getmessage>> GetmessageAsync(int productId)
{
	// Initialization.  
	List<Getmessage> lst = new List<Getmessage>();

	try
	{
		// Settings.  
		SqlParameter usernameParam = new SqlParameter("@id", productId.ToString() ?? (object)DBNull.Value);

		// Processing.  
		string sqlQuery = "EXEC [dbo].[Getmessage] " +
						  "@id";

		lst = await this.Query<Getmessage>().FromSql(sqlQuery, usernameParam).ToListAsync();
	}
	catch (Exception ex)
	{
		throw ex;
	}
}
Posted
Updated 20-Feb-19 4:04am
v2
Comments
Richard Deeming 20-Feb-19 10:20am
   
Have you registered the Getmessage type as a query type[^]?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

   
Comments
Richard Deeming 20-Feb-19 10:16am
   
Those seem to be related to Entity Framework, not Entity Framework Core. IIRC, EF Core has some significant differences around stored procedures.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190518.1 | Last Updated 20 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100