-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainViewModel.cs
37 lines (36 loc) · 1.21 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
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 {
EntityServerModeSource _ItemsSource;
public EntityServerModeSource ItemsSource {
get
{
if(_ItemsSource == null) {
var context = new IssuesContext();
_ItemsSource = new EntityServerModeSource {
KeyExpression = nameof(Issue.Id),
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;
}
}
}
}