linq2db / linq2db.LINQPad

linq2db.LINQPad is a driver for LINQPad.
MIT License
74 stars 24 forks source link

Fix problems when using a custom IDataContext implementation #102

Closed cal-tlabwest closed 8 months ago

cal-tlabwest commented 10 months ago

Some code assumes only DataConnection or DataContext can implement IDataContext. This PR fixes some of these assumptions.

Note: Will try to find a "public Action OnTraceConnection" property on the custom IDataContext class. Add something like this If you have a custom implementation that wraps an internal DataContext:

// Important for LinqPad public Action OnTraceConnection { get => Context.OnTraceConnection; set => Context.OnTraceConnection = value; }

MaceWindu commented 8 months ago

Could you clarify what kind of context you have so it doesn't derive DataConnection or DataContext?

MaceWindu commented 8 months ago

merged by https://github.com/linq2db/linq2db.LINQPad/commit/f1d1bf598fd21af332db92ee3f8f9b107677fda6

cal-tlabwest commented 7 months ago

Could you clarify what kind of context you have so it doesn't derive DataConnection or DataContext?

We're just trying to control API surfaces exposed in our project:

public class MyContext: IDataContext { DataConnection Context { get; }

// Wrap Context Func IDataContext.CreateSqlProvider => ((IDataContext)Context).CreateSqlProvider; ... }