Hello. Faced a problem when accessing postgresql - when loading data from another table, the connection is not closed, even if I wrap dbContext in using, without loading data from another table, the connections are closed correctly. I use linq2db.
Here is the actual action that is called:
[HttpGet] public PageModel<Client> GetAllClientInformation(WebApiEntityPageCondition<Client> condition) { using (var db = new HybridCrmEssence(GlobalConfig.Database.PostgreCrm)) { var d = from cli in db.Clients.LoadWith(p => p.Contacts) select cli; return new PageModel<Client>() { Items = d.ToArray() }; } }
Base context:
public class HybridCrmEssence : DataConnection { public HybridCrmEssence(string connectionString) : base(new PostgreSQLDataProvider(), connectionString) { } public ITable<Client> Clients { get { return GetTable<Client>(); } } public ITable<Contact> Contacts { get { return GetTable<Contact>(); } } }
And the models themselves:
[Table("Clients")] public class Client : DbModel { [Association(ThisKey = "Id", OtherKey = "ClientId")] public List<Contact> Contacts { get; set; } } [Table("Contacts")] public class Contact : DbModel { [Column] public int ClientId { get; set; } }
In DbModel, I myself have stored it. What could be the problem?