绑定的ObservableCollection数据库 [英] Bind ObservableCollection to database

查看:83
本文介绍了绑定的ObservableCollection数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类:

[Table]
public class myClass
{
    [Column(IsPrimaryKey = true)]
    public int ID { get; set; }

    [Column]
    public string Type { get; set; }
}

和为了从我的数据库表MyClass的加载数据如下code:

And the following code in order to load the data from my database table "myClass":

static public readonly ObservableCollection<myClass> items;
DataContext dataContext = new DataContext("Secret");

var ruleTable = dataContext.GetTable<myClass>();

IQueryable<Rule> custQuery = ruleTable.Select(tableName => tableName);
items = new ObservableCollection<myClass>(custQuery);

我怎样才能使基于数据库的更新我的的ObservableCollection

推荐答案

这$ C $的CProject文章中,我写了一个前阵子有一节,详细说明执行数据库更新/删除/从绑定的WPF数据网格的插入操作:

This codeproject article I wrote a while back has a section that details performing database update / delete / insert operations from a bound WPF datagrid:

WPF DataGrid中的实际例子

这篇关于绑定的ObservableCollection数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆