views:

39

answers:

1

Hello

For the past few weeks I have been really struggling doing something that should be really simple!

I have a stored procedure in a database which I call twice. Each call results in totally different data. I need the entity framework to treat it like this

At the moment it caches everything

So I am going to ask for help in a different way!

Could someone show me how do this in this situation:

tblInvoice table
Amount Float
InvoiceDate dateTime

Invoice Data:
AccountID: 1 InvoiceDate: 12 Dec 2009 Amount: 100
AccountID: 1 InvoiceDate: 11 Dec 2009 Amount: 150
AccountID: 2 InvoiceDate: 11 Nov 2008 Amount: 150

Stored Procedure spGetInvoicesForDateRange - Returns all invoices for date range

  1. spGetInvoicesForDateRange 01 Dec 2009 - 31 Dec 2009
  2. spGetInvoicesForDateRange 01 Nov 2008 - 30 Nov 2008

At present, with my code executing 2 above would still return the results of 1 but executing 2) should only return the invoice for 11 nov 2008

My model is generated using Entity Framework but my context inherits from ObjectContext so I cant use ObjectTrackingEnabled

If someone could show me how to do the above I can then try to adapt it to my situation

Cheers

Paul

A: 

What is the datatype of parameters of the stored procedure? Can you send DDL of it?

Piotr Rodak
It would just be something like CREATE PROCEDURE spGetInvoicesForDateRange(@dtStart datetime, @dtEnd datetime) AS SELECT AccountID, InvoiceDate, AmountFROM tblInvoiceWHERE InvoiceDate BETWEEN @dtStart and @dtEndMy scenario is more complex than this but if someone could show me how to get a stored procedure that has been added to a model to show independant results, e.g. no caching, then I can adaptI do have the Microsoft Adventure works database and model if its easier to demonstrate from there, but need to remember that my model inherits from ObjectContext not DataContext
Paul
sorry I dont know how to format a comment
Paul