-
Notifications
You must be signed in to change notification settings - Fork 5
LINQPadDataEditor
Like others I have taken the The LINQPad Challenge but I found myself having to go back to SQL Server Management Studio to edit data. So to further eliminate trips to that place I have created a DataGridView based DataEditor and accompanying IEnumerable and IQueryable Extensions to edit the results of queries. Coincidentally this implements this LINQPad feature suggestion open table for edit as in sql server mgmt studio and now also implemented as aCustom Visualizer.
The contents of the DataEditor can also copied to the clipboard as CSV or exported to Excel or PDF via a Microsoft.Reporting.WinForms.ReportViewer control.
The LINQPad DataEditor shows the normal properties that a datagridview would show plus public fields - this has been done as it seems the automatic LINQToSQL datacontext uses fields rather than properties.
If you are using the Static LLBLGen Pro Data Context Driver this is included and should be available for queries using this driver. If not, download and reference myEnumerable Debugger Visualizer which is a merge of all the assemblies required.
Call one of these extension methods:
public static IEnumerable ShowInGrid(this IQueryable enumerable, ushort pageSize)
public static IEnumerable ShowInGrid(this IEnumerable enumerable, IDataEditorPersister gridDataEditorPersister)
public static IEnumerable ShowInGrid(this IEnumerable enumerable, IDataEditorPersister gridDataEditorPersister, ushort pageSize)
public static IEnumerable<T> ShowInGrid<T>(this IEnumerable<T> enumerable, IDataEditorPersister gridDataEditorPersister)
public static IEnumerable<T> ShowInGrid<T>(this IEnumerable<T> enumerable, IDataEditorPersister gridDataEditorPersister, ushort pageSize)
// LINQToSQL
public static IEnumerable<T> ShowInGrid<T>(this Table<T> table) where T : class
public static IEnumerable<T> ShowInGrid<T>(this Table<T> table, ushort pageSize) where T : class
public static IEnumerable<T> ShowInGrid<T>(this IQueryable<T> dataQuery, DataContext dataContext) where T : class
public static IEnumerable<T> ShowInGrid<T>(this IQueryable<T> dataQuery, DataContext dataContext, ushort pageSize) where T : class
// LLBL
public static IEnumerable<T> ShowSelfServicingInGrid<T>(this IEnumerable<T> enumerable, ushort pageSize) where T : EntityBase
public static IEnumerable<T> ShowSelfServicingInGrid<T>(this IEnumerable<T> enumerable) where T : EntityBase
public static IEnumerable ShowInGrid(this IEnumerable enumerable, IDataAccessAdapter dataAccessAdapter, ushort pageSize)
public static IEnumerable<T> ShowInGrid<T>(this IEnumerable<T> enumerable, IDataAccessAdapter dataAccessAdapter, ushort pageSize) where T : EntityBase2
public static IEnumerable<T> ShowAdapterInGrid<T>(this IQueryable<T> query, ushort pageSize) where T : EntityBase2
public static IEnumerable<T> ShowAdapterInGrid<T>(this IQueryable<T> query) where T : EntityBase2
The GridDataEditor is paged and defaults to a page size of 30, note that clicking a column sorts the current page not the whole enumeration as is normal in paged grids.
The results of the edits can then be chained to other operations down the line such as LINQPad's dump command.
To save the changes to the DB a DataEditorPersister must be supplied, except for LINQToSQL and LLBL queries, where there are extension methods which use built-in LINQToSQL and LLBL DataEditorPersisters. If no DataEditorPersister is provided and the data is IQueryable then the DataEditor will be in readonly mode, if the data is IEnumerable only the output will reflect the results of any editing.
NutShell
AW.Winforms.Helpers.DataEditor.DataEditorExtensions.ShowInGrid(Customers).Dump ("All customers");Customers.ShowInGrid();
Northwind
Customers.ShowInGrid()
SourceCode
EditInDataGridView*.linq and ShowInGrid*.linq files in the SampleQueryFiles folder.
- Improve the paging
- Support filtering