This question is locked. New answers and comments are not allowed.
I guess I'm just using OpenAccess incorrectly, because it keeps breaking inconsistently... one moment the code works perfectly fine, then when I'm off working on another screen and go back to previous sections in the website, OpenAccess starts throwing Invalid Handle and Shared Memory errors.... Can you not use OpenAccess as written in the two code snippets below??
****** Snippet #1 ********
public IList<Customer> GetCustomers(Guid userId)
{
IList<Customer> customers = null;
using (UserAdminContext dbContext = new UserAdminContext("AdminConnection"))
{
var query = from c in dbContext.Customers
from a in c.UserCustomerAssociations
where a.UserId == userId
select new Customer() { CustomerNumber = c.CustomerNumber, CompanyName = c.CompanyName, Identifier = c.Identifier };
customers = query.ToList<Customer>();
}
return customers;
}
******** Snippet #2 **********
public IDictionary<string, string> GetGeoLevels()
{
IDictionary<string, string> levels = new Dictionary<string, string>();
using (ParentChildSummaryContext dbContext = new ParentChildSummaryContext("PCSConnection"))
{
var retailer = (from r in dbContext.SupplyChainRetailers
where r.RetailerCode == "LOW"
select r).FirstOrDefault();
if (retailer != null)
{
levels.Add("G1", retailer.Attribute1);
levels.Add("G2", retailer.Attribute2);
levels.Add("G3", retailer.Attribute3);
levels.Add("G4", retailer.Attribute4);
levels.Add("G5", retailer.Attribute5);
}
}
return levels;
}
I don't believe these are very complex by any stretch of the imagination and worry that when I do get to more complex scenarios it will crash and burn if it can't even do these simple tasks....?? :(
****** Snippet #1 ********
public IList<Customer> GetCustomers(Guid userId)
{
IList<Customer> customers = null;
using (UserAdminContext dbContext = new UserAdminContext("AdminConnection"))
{
var query = from c in dbContext.Customers
from a in c.UserCustomerAssociations
where a.UserId == userId
select new Customer() { CustomerNumber = c.CustomerNumber, CompanyName = c.CompanyName, Identifier = c.Identifier };
customers = query.ToList<Customer>();
}
return customers;
}
******** Snippet #2 **********
public IDictionary<string, string> GetGeoLevels()
{
IDictionary<string, string> levels = new Dictionary<string, string>();
using (ParentChildSummaryContext dbContext = new ParentChildSummaryContext("PCSConnection"))
{
var retailer = (from r in dbContext.SupplyChainRetailers
where r.RetailerCode == "LOW"
select r).FirstOrDefault();
if (retailer != null)
{
levels.Add("G1", retailer.Attribute1);
levels.Add("G2", retailer.Attribute2);
levels.Add("G3", retailer.Attribute3);
levels.Add("G4", retailer.Attribute4);
levels.Add("G5", retailer.Attribute5);
}
}
return levels;
}
I don't believe these are very complex by any stretch of the imagination and worry that when I do get to more complex scenarios it will crash and burn if it can't even do these simple tasks....?? :(