Hello
I have had a problem where it appeared as though the second execution of a stored procedure was being ignored.
The first time I call my stored procedure it found 20 records and extracted information for the date range August 2009. The first line was meter id 233 with a data value 200
I then called the stored procedure and 20 records were also returned. This time meter id 233 had a data value of 300.
Linq is detecting that meterid 233 already exists in the context and so doesnt update
I am sure this is something to do with ObjectTrackingEnabled but this does not seem to be available for me to set to false?
I didnt write the context code so I dont really know how it all works, but I have noticed that it seems to inherit from ObjectDataContext
This was generate using Entity Framework and VS 2008
namespace DataServiceDAL {
/// <summary>
/// There are no comments for dbChildDataContext in the schema.
/// </summary>
public partial class dbChildDataContext : global::System.Data.Objects.ObjectContext
{
/// <summary>
/// Initializes a new dbChildDataContext object using the connection string found in the 'dbChildDataContext' section of the application configuration file.
/// </summary>
public dbChildDataContext() :
base("name=dbChildDataContext", "dbChildDataContext")
{
this.OnContextCreated();
}
/// <summary>
/// Initialize a new dbChildDataContext object.
/// </summary>
public dbChildDataContext(string connectionString) :
base(connectionString, "dbChildDataContext")
{
this.OnContextCreated();
}
/// <summary>
/// Initialize a new dbChildDataContext object.
/// </summary>
public dbChildDataContext(global::System.Data.EntityClient.EntityConnection connection) :
base(connection, "dbChildDataContext")
{
this.OnContextCreated();
}
partial void OnContextCreated();
.............. }
I use the following linq to extract the data
public static List<MeterTotalConsumpRecord> GetTotalAllTimesConsumption(DateTime dtStart, DateTime dtEnd, EUtilityGroup ug, int nMeterSelectionType, int nCustomerID,
int nUserID, string strSelection, bool bClosedLocations, bool bDisposedLocations)
{
dbChildDataContext db = DBManager.ChildDataConext(nCustomerID);
var tbl = from t in db.GetTotalConsumptionByMeter(dtStart, dtEnd, (int) ug, nMeterSelectionType, nCustomerID, nUserID, strSelection, bClosedLocations, bDisposedLocations, 1)
select t;
return tbl.ToList();
}
I need a way of clearing this cache out so that the objects are updated properly or I need a way of refreshing the objects
Can anyone help?
Cheers
Paul