TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
creator trainer
NA
3
3.2k
stored procedure in sql with EF and web API
Jan 27 2018 5:02 AM
Dear Mr,
In case I need to use a stored procedure from DB in sql server and this stored procedure has many parameters and many join to many tables and return many fields from many table how to call and use it with WEB API Controller?
Many thanks and best regards,
Example : EF
public virtual DbSet<T_Clubs> T_Clubs { get; set; }
public virtual DbSet<T_Games> T_Games { get; set; }
public virtual DbSet<T_Reservations> T_Reservations { get; set; }
//HOW TO USE THIS WITH WEB API Controller this a stored procedure in DB ?!! PLease advice
public virtual int GetReservationsByClubId(Nullable<int> clubId)
{
var clubIdParameter = clubId.HasValue ?
new ObjectParameter("ClubId", clubId) :
new ObjectParameter("ClubId", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("GetReservationsByClubId", clubIdParameter);
}
//HOW TO USE THIS WITH WEB API Controller this a stored procedure in DB ?!! PLease advice
public virtual ObjectResult<GetReservations_Result> GetReservations()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetReservations_Result>("GetReservations");
}
//HOW TO USE THIS WITH WEB API Controller this a stored procedure in DB ?!! PLease advice?
Thank you and best regards
Reply
Answers (
1
)
Details Of C# 7.1
Generate Reporting and Email Attachement