I'm new to EF and have just created a new stored procedure to return some basic info
CREATE PROCEDURE GetTop10Clients
@AccountId NVARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT TOP 10
Client.Name, Count(Client.Name) AS Number
FROM
WHERE
(Client.AccountId = @AccountId)
GROUP BY
Client.Name
ORDER BY
Number DESC
END
GO
I've then added to my edmx and have created a function import called GetTop10Clients to return a complex GetTop10Clients_Result (followed http://www.entityframeworktutorial.net/EntityFramework4.3/execute-stored-procedure-using-dbcontext.aspx)
But I can't figure out how to call it
namespace ClientSystem.Repositories.Ef
{
public class AccountRepository : IAccountRepository
{
public AccountRepository(ObjectSet<Account> set ,ObjectContext ctx) : base(ctx,set)
{
}
public DashboardStats GetTop10Stats(string accountId)
{
//var results = GetTop10Clients(accountId); ??????
return null;
}
}
}
Thank you for your help, example would be great.
You will have one function generated in
objectcontext/dbcontextlike following.You can call that method like following.