年末将至,由于各种原因Lor最近没有任何进展,实在可惜。不过为了给大家一个补偿,以下奉献出一段Lor的C#代码使用,看看Lor与其他O/R Mapping产品相比有什么与众不同之处。
BookList books = (BookList) DataCenter.Query("select {Book.Price} from {Book} where year({Book.PublishedDate})=1993 and {Book.Authors.LastName}='张'");
foreach (Book book in books) {
book.Authors[0].LastName.Value = "袁";
if (book.Price.IsValid(book.Price.Value * 0.80)) {
book.Price.Value = book.Price.Value * 0.80;
}
}
// 将整个List作为事务。
SaveResult result = books.Save();
if (result.Failed) {
if (result.FailedReason == FailedReason.DataConflict) {
result.CommitOverwrite();
// result.Ignore();
} else {
result.Rollback();
}
}
//
// 与用户控件的绑定。
//
books.DefaultView.Bind("C#", new string[] {"Name", "Price", "Authors Name = Authors[*].Name"});
books.DefaultView.Filter("C#", "Authors.Count > 1 && Authors[*].Address.City == /"长春/"");
books.DefaultView.Sort("C#", new string[] {"Price, DES", "Name, ASC", "Authors[0].Name, ASC"});
this.dataGrid1.DataSource = books;
BookList books = (BookList) DataCenter.Query("select {Book.Price} from {Book} where year({Book.PublishedDate})=1993 and {Book.Authors.LastName}='张'");
foreach (Book book in books) {
book.Authors[0].LastName.Value = "袁";
if (book.Price.IsValid(book.Price.Value * 0.80)) {
book.Price.Value = book.Price.Value * 0.80;
}
}
// 将整个List作为事务。
SaveResult result = books.Save();
if (result.Failed) {
if (result.FailedReason == FailedReason.DataConflict) {
result.CommitOverwrite();
// result.Ignore();
} else {
result.Rollback();
}
}
//
// 与用户控件的绑定。
//
books.DefaultView.Bind("C#", new string[] {"Name", "Price", "Authors Name = Authors[*].Name"});
books.DefaultView.Filter("C#", "Authors.Count > 1 && Authors[*].Address.City == /"长春/"");
books.DefaultView.Sort("C#", new string[] {"Price, DES", "Name, ASC", "Authors[0].Name, ASC"});
this.dataGrid1.DataSource = books;BookList books = (BookList) DataCenter.Query("select {Book.Price} from {Book} where year({Book.PublishedDate})=1993 and {Book.Authors.LastName}='张'");
foreach (Book book in books) {
book.Authors[0].LastName.Value = "袁";
if (book.Price.IsValid(book.Price.Value * 0.80)) {
book.Price.Value = book.Price.Value * 0.80;
}
}
// 将整个List作为事务。
SaveResult result = books.Save();
if (result.Failed) {
if (result.FailedReason == FailedReason.DataConflict) {
result.CommitOverwrite();
// result.Ignore();
} else {
result.Rollback();
}
}
//
// 与用户控件的绑定。
//
books.DefaultView.Bind("C#", new string[] {"Name", "Price", "Authors Name = Authors[*].Name"});
books.DefaultView.Filter("C#", "Authors.Count > 1 && Authors[*].Address.City == /"长春/"");
books.DefaultView.Sort("C#", new string[] {"Price, DES", "Name, ASC", "Authors[0].Name, ASC"});
this.dataGrid1.DataSource = books;以上是一段用Lor得到的C#源代码写的示例,其中展示了一部分Lor在.NET平台下的独特之处。这里所展示的只是在目前设计阶段决定采用的调用方式,在后期很有可能还会变化,敬请期待!^_^
年末Lor进展不佳,作者奉献一段Lor的C#代码示例。代码包含数据查询、修改、保存,以及与用户控件绑定、过滤、排序等操作,展示了Lor在.NET平台下的独特之处,且调用方式后期可能变化。
1168

被折叠的 条评论
为什么被折叠?



