我是靠谱客的博主 冷傲魔镜,最近开发中收集的这篇文章主要介绍ServiceStack.OrmLite,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

LINQ很強大,不過有一點做不了,就是批量更新,刪除。而這個框架就實現了這個功能,令我喜出望外。

下載for sql server
PM> Install-Package ServiceStack.OrmLite.SqlServer -Version 4.0.30
http://www.nuget.org/packages/ServiceStack.OrmLite.SqlServer/4.0.30

https://github.com/ServiceStack/ServiceStack.OrmLite

1.Dictionary returns a Dictionary made from the first two columns:

Dictionary<int, string> trackIdNamesMap = db.Dictionary<int, string>(
"select Id, Name from Track")

2.Lookup returns an Dictionary<K, List<V>> made from the first two columns:

Dictionary<int, List<string>> albumTrackNames = db.Lookup<int, string>(
"select AlbumId, Name from Track")


3.Reference Support, POCO style

OrmLite lets you Store and Load related entities in separate tables using [Reference] attributes in primary tables in conjunction with {Parent}Id property convention in child tables, e.g:

public class Customer
{

[AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }

[Reference] // Save in CustomerAddress table
public CustomerAddress PrimaryAddress { get; set; }

[Reference] // Save in Order table
public List<Order> Orders { get; set; }
}
public class CustomerAddress
{

[AutoIncrement]
public int Id { get; set; }
public int CustomerId { get; set; } //`{Parent}Id` convention to refer to Customer
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
}
public class Order
{

[AutoIncrement]
public int Id { get; set; }
public int CustomerId { get; set; } //`{Parent}Id` convention to refer to Customer
public string LineItem { get; set; }
public int Qty { get; set; }
public decimal Cost { get; set; }
}


使用 ServiceStack.Text 序列化 json的实现代码
使用 ServiceStack.Text 序列化 json的实现代码
http://www.educity.cn/develop/688760.html

 

转载于:https://www.cnblogs.com/sui84/p/6777072.html

最后

以上就是冷傲魔镜为你收集整理的ServiceStack.OrmLite的全部内容,希望文章能够帮你解决ServiceStack.OrmLite所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部