-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainViewModel.cs
39 lines (38 loc) · 1.31 KB
/
MainViewModel.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
37
38
39
using DevExpress.Mvvm;
using EFCoreIssues.Issues;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Data.Linq;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections;
namespace EFCoreIssues {
public class MainViewModel : ViewModelBase {
EntityInstantFeedbackSource _ItemsSource;
public EntityInstantFeedbackSource ItemsSource {
get
{
if(_ItemsSource == null) {
_ItemsSource = new EntityInstantFeedbackSource {
KeyExpression = nameof(Issue.Id)
};
_ItemsSource.GetQueryable += (sender, e) => {
var context = new IssuesContext();
e.QueryableSource = context.Issues.AsNoTracking();
};
}
return _ItemsSource;
}
}
IList _Users;
public IList Users {
get
{
if(_Users == null && !DevExpress.Mvvm.ViewModelBase.IsInDesignMode) {
var context = new IssuesContext();
_Users = context.Users.Select(user => new { Id = user.Id, Name = user.FirstName + " " + user.LastName }).ToArray();
}
return _Users;
}
}
}
}