ram27
asked on
Error while adding the stored proc manually in Entity frame work and trying call it from Web Api
Hi i am having below issue when trying to call a stored proc from web Api , below is my code
Model:
public class SF_Oculus_ListingsLast4Day s_Vw
{
[Key]
[DatabaseGenerated(Databas eGenerated Option.Non e)]
public Int64? OculusListingsID { get; set; }
public int? MLSID { get; set; }
[StringLength(255)]
public String MLSName { get; set; }
[StringLength(100)]
public String MLSAgentID { get; set; }
[StringLength(100)]
public String MLSOfficeID { get; set; }
Controller :
[ODataRoutePrefix("SF_Ocul us_Listing sLast4Days _Vw")]
public class SF_Oculus_ListingsLast4Day s_VwContro ller : ODataController
{
readonly OrdersModel _db = new OrdersModel();
Action<OrdersModel> SetTimeOut = (OrdersModel _db) =>
{
if (_db != null)
_db.Database.CommandTimeou t = Constants.Constants.SqlTim eOut;
};
[ODataRoute]
[EnableQuery(PageSize = 20, AllowedQueryOptions = AllowedQueryOptions.All)]
public IHttpActionResult Get([FromODataUri] string SF_OwnerID)
{
SetTimeOut(_db);
return Ok(_db.SF_Oculus_ListingsL ast4Days_V w(SF_Owner ID).AsQuer yable());
}
//[ODataRoute("({key})")]
[EnableQuery(PageSize = 20, AllowedQueryOptions = AllowedQueryOptions.All)]
public IHttpActionResult Get([FromODataUri] int key, [FromODataUri] string SF_OwnerID)
{
SetTimeOut(_db);
return Ok(_db.SF_Oculus_ListingsL ast4Days_V w(SF_Owner ID));
}
Ordermodel..cs:
public partial class OrdersModel : DbContext
{
public OrdersModel()
: base("name=OrdersModel")
{
}
public virtual DbSet<FileParty> FileParty { get; set; }
public virtual System.Data.Entity.Core.Ob jects.Obje ctResult<S F_Oculus_L istingsLas t4Days_Vw> SF_Oculus_ListingsLast4Day s_Vw(strin g SF_OwnerID)
{
var SF_OwnerIDParameter = new ObjectParameter("SF_OwnerI D", SF_OwnerID);
return ((System.Data.Entity.Infra structure. IObjectCon textAdapte r)this).Ob jectContex t.ExecuteF unction<SF _Oculus_Li stingsLast 4Days_Vw>( "DD_SalesF orce_Oculu s_Listings Last4Days" , SF_OwnerIDParameter);
}
DD_salesForce_Oculus_Listi ngLast4day s is my stored proc
webapiconfig.cs
config.MapODataServiceRout e("odata", "odata", GetEdmModel());
config.EnsureInitialized() ;
private static IEdmModel GetEdmModel()
{
EntitySetConfiguration<SF_ Oculus_Lis tingsLast4 Days_Vw> SF_Oculus_ListingsLast4Day s_Vws = builder.EntitySet<SF_Oculu s_Listings Last4Days_ Vw>
("SF_Oculus_ListingsLast4D ays_Vw");
FunctionConfiguration SF_Oculus_ListingsLast4Day s_VwDetail s = SF_Oculus_ListingsLast4Day s_Vws.Enti tyType.Col lection.Fu nction("SF _Oculus_Li stingsLast 4Days_VwGe t");
SF_Oculus_ListingsLast4Day s_VwDetail s.Paramete r<string>( "SF_OwnerI D");
SF_Oculus_ListingsLast4Day s_VwDetail s.ReturnsC ollectionF romEntityS et<SF_Ocul us_Listing sLast4Days _Vw>("SF_O culus_List ingsLast4D ays_Vw");
return builder.GetEdmModel();
}
When trying to run the records from stored proc calling from odata like below
https://test.sfservices.firstam.com/SalesForceREST/odata/SF_Oculus_ListingsLast4Days_Vw?%24filter=SF_OwnerID%20eq%20%2727005j000000C6Ya5AAF%27
I am getting the error :
{
"error":{
"code":"","message":"No HTTP resource was found that matches the request URI 'https://test.sfservices.firstam.com/SalesForceREST/odata/SF_Oculus_ListingsLast4Days_Vw?%24filter=SF_OwnerID eq '27005j000000C6Ya5AAF''."
}
}
Can you let me know what I am missing and where is the problem.
Thanks!
Model:
public class SF_Oculus_ListingsLast4Day
{
[Key]
[DatabaseGenerated(Databas
public Int64? OculusListingsID { get; set; }
public int? MLSID { get; set; }
[StringLength(255)]
public String MLSName { get; set; }
[StringLength(100)]
public String MLSAgentID { get; set; }
[StringLength(100)]
public String MLSOfficeID { get; set; }
Controller :
[ODataRoutePrefix("SF_Ocul
public class SF_Oculus_ListingsLast4Day
{
readonly OrdersModel _db = new OrdersModel();
Action<OrdersModel> SetTimeOut = (OrdersModel _db) =>
{
if (_db != null)
_db.Database.CommandTimeou
};
[ODataRoute]
[EnableQuery(PageSize = 20, AllowedQueryOptions = AllowedQueryOptions.All)]
public IHttpActionResult Get([FromODataUri] string SF_OwnerID)
{
SetTimeOut(_db);
return Ok(_db.SF_Oculus_ListingsL
}
//[ODataRoute("({key})")]
[EnableQuery(PageSize = 20, AllowedQueryOptions = AllowedQueryOptions.All)]
public IHttpActionResult Get([FromODataUri] int key, [FromODataUri] string SF_OwnerID)
{
SetTimeOut(_db);
return Ok(_db.SF_Oculus_ListingsL
}
Ordermodel..cs:
public partial class OrdersModel : DbContext
{
public OrdersModel()
: base("name=OrdersModel")
{
}
public virtual DbSet<FileParty> FileParty { get; set; }
public virtual System.Data.Entity.Core.Ob
{
var SF_OwnerIDParameter = new ObjectParameter("SF_OwnerI
return ((System.Data.Entity.Infra
}
DD_salesForce_Oculus_Listi
webapiconfig.cs
config.MapODataServiceRout
config.EnsureInitialized()
private static IEdmModel GetEdmModel()
{
EntitySetConfiguration<SF_
("SF_Oculus_ListingsLast4D
FunctionConfiguration SF_Oculus_ListingsLast4Day
SF_Oculus_ListingsLast4Day
SF_Oculus_ListingsLast4Day
return builder.GetEdmModel();
}
When trying to run the records from stored proc calling from odata like below
https://test.sfservices.firstam.com/SalesForceREST/odata/SF_Oculus_ListingsLast4Days_Vw?%24filter=SF_OwnerID%20eq%20%2727005j000000C6Ya5AAF%27
I am getting the error :
{
"error":{
"code":"","message":"No HTTP resource was found that matches the request URI 'https://test.sfservices.firstam.com/SalesForceREST/odata/SF_Oculus_ListingsLast4Days_Vw?%24filter=SF_OwnerID eq '27005j000000C6Ya5AAF''."
}
}
Can you let me know what I am missing and where is the problem.
Thanks!
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.