-
Notifications
You must be signed in to change notification settings - Fork 6
/
MainWindow.xaml.cs
36 lines (31 loc) · 1007 Bytes
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Windows;
using EFCoreIssues.Issues;
using System.Linq;
using DevExpress.Xpf.Grid;
namespace EFCoreIssues {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
LoadData();
}
IssuesContext _Context;
void LoadData() {
_Context = new IssuesContext();
grid.ItemsSource = _Context.Users.ToList();
}
void OnValidateRow(object sender, GridRowValidationEventArgs e) {
var row = (User)e.Row;
if(e.IsNewItem)
_Context.Users.Add(row);
_Context.SaveChanges();
}
void OnValidateRowDeletion(object sender, GridValidateRowDeletionEventArgs e) {
var row = (User)e.Rows.Single();
_Context.Users.Remove(row);
_Context.SaveChanges();
}
void OnDataSourceRefresh(object sender, DataSourceRefreshEventArgs e) {
LoadData();
}
}
}