轮子来袭 vJine.Core Orm 之 01_快速体验
vJine.Core 是.Net环境下C#类库,在其包含的众多功能中ORM功能尤为突出,现简介如下。
一、支持的数据库:
SQLite, MySQL, MS SQL, Oracle。
二、使用方法:
0.添加引用:
库文件vJine.Core.dll,
using vJine.Core;
using vJine.Core.ORM;
1.定义类:
using System;
using System.Collections.Generic;
using System.Text;
using vJine.Core.Base;
using vJine.Core.IO;
using vJine.Core.ORM; namespace vJineCore_QuickStart.BML { public class My_Model : ItemBase /*不是必须继承*/ {
public My_Model() {
this.ID = Guid.NewGuid().ToString("N");
} public partial class _ {
public static readonly Property<My_Model, string> ID = new Property<My_Model, string>("ID");
}
string _ID;
[Key(IsPrimary=true)] //指定主键
public string ID {
get {
return this._ID;
}
set {
if (value != this._ID) {
this._ID = value;
this.NotifyPropertyChanged("ID");
}
}
} bool _IsActive;
public bool IsActive {
get {
return this._IsActive;
}
set {
if (value != this._IsActive) {
this._IsActive = value;
this.NotifyPropertyChanged("IsActive");
}
}
} public enum Status:byte {
Unknown = ,
Ready = ,
Running = ,
Done =
} Status _MyStatus;
public partial class _ {
public static readonly Property<My_Model, Status> MyStatus = new Property<My_Model, Status>("MyStatus");
}
public Status MyStatus { //支持枚举类型
get {
return this._MyStatus;
}
set {
if (value != this._MyStatus) {
this._MyStatus = value;
this.NotifyPropertyChanged("MyStatus");
}
}
} public partial class _ {
public static readonly Property<My_Model, int> Qty = new Property<My_Model, int>("Qty");
}
int _Qty;
public int Qty {
get {
return this._Qty;
}
set {
if (value != this._Qty) {
this._Qty = value;
this.NotifyPropertyChanged("Qty");
}
}
} DateTime _Stamp;
public DateTime Stamp {
get {
return this._Stamp;
}
set {
if (value != this._Stamp) {
this._Stamp = value;
this.NotifyPropertyChanged("Stamp");
}
}
}
}
}
2.配置连接:
<connectionStrings>
<add name="Default" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=【数据库名称】;Integrated Security=True"/>
</connectionStrings>
注:请将【数据库名称】改为你本地对应的数据库名。
3.新建实例:
DataManager dm = new DataManager(); //引用Default配置
DataManager dm = new DataManager("specific_name"); //引用指定配置
4.创建数据表:
//Create Table
dm.Create<My_Model>();
5.增删改查:
My_Model new_data = new My_Model() {
Qty = , IsActive = false, MyStatus = My_Model.Status.Ready
};
new_data.Stamp = dm.Now;
dm.I<My_Model>(new_data);
dm.D<BML.My_Model>(BML.My_Model._.ID == "xxx");
dm.U<BML.My_Model>(My_Model._.Qty.EQ(My_Model._.Qty + 1) & My_Model._.MyStatus.EQ(My_Model.Status.Running), My_Model._.MyStatus == My_Model.Status.Ready);
List<My_Model> container = new List<My_Model>();
//先定义一个实现IList<>接口的对象容器,查询结果将累加填充
dm.Q<My_Model>(container, My_Model._.ID.Like("ABC%") & My_Model._.Qty > );
三、附件:
四、附注:
1、默认连接配置为 MS SQL Server,未保证测试顺利进行,请优先使用MS SQL Server, connectionString请依据您服务器的实际情况更改。
2、本篇仅作为功能体验的引导文章,后续将陆续推出使用细则、架构设计等相关内容。
3、vJine.Core将已开源模式提供,可用免费于私人和商业用途,但作者本人不反使用者通过以下方式给以赞同(顶贴、点赞、推荐)。
4、关于性能:性能方面个人暂无比较,如有热衷于这方面的朋友帮忙做个测试,将不胜感激。
5、vJine.Core的目标是:简洁、高效、轻量级、非侵入。
轮子来袭 vJine.Core Orm 之 01_快速体验的更多相关文章
- 轮子来袭 vJine.Core Orm 之 03_架构分析
1.vJine.Core ORM 架构: 如上图所示,vJine.Core ORM的特点如下: 所有操作均以DataManager为核心: DataManager业务部分的增删改查操作依赖于Class ...
- 轮子来袭 vJine.Core Orm 之 04_使用进阶
1.配置文件: 框架默认情况下支持"connectionStrings"的配置方式,如<轮子来袭 vJine.Core Orm 之 01_快速入门>所述: 框架的进阶设 ...
- 轮子来袭 vJine.Core Orm 之 02_代码生成
1.下载并安装动软代码生成器: 2.下载vJine.Core.Orm模板: 3.解压模本文件并复制到如下的动软代码生成器模板目录: 4.打开动软代码生成器会看到模板已识别加载: 5.选择模板代码批量生 ...
- 轮子来袭 vJine.Core 之 AppConfig<T>
1.引用vJine.Core; 2.定义配置类; using System; using System.Collections.Generic; using System.Text; using Sy ...
- .NET Core前后端分离快速开发框架(Core.3.0+AntdVue)
.NET Core前后端分离快速开发框架(Core.3.0+AntdVue) 目录 引言 简介 环境搭建 开发环境要求 基础数据库构建 数据库设计规范 运行 使用教程 全局配置 快速开发 管理员登录 ...
- [转].NET Core前后端分离快速开发框架(Core.3.0+AntdVue)
[转].NET Core前后端分离快速开发框架(Core.3.0+AntdVue) 目录 引言 简介 环境搭建 开发环境要求 基础数据库构建 数据库设计规范 运行 使用教程 全局配置 快速开发 管理员 ...
- vJine.Core 0.3.0.49 正式发布
nuget: https://www.nuget.org/packages/vJine.Core/ oschina: http://git.oschina.net/vjine/vJine.Core/a ...
- .Net Core ORM选择之路,哪个才适合你 通用查询类封装之Mongodb篇 Snowflake(雪花算法)的JavaScript实现 【开发记录】如何在B/S项目中使用中国天气的实时天气功能 【开发记录】微信小游戏开发入门——俄罗斯方块
.Net Core ORM选择之路,哪个才适合你 因为老板的一句话公司项目需要迁移到.Net Core ,但是以前同事用的ORM不支持.Net Core 开发过程也遇到了各种坑,插入条数多了也特别 ...
- .Net Core 3.0 IdentityServer4 快速入门
.Net Core 3.0 IdentityServer4 快速入门 一.简介 IdentityServer4是用于ASP.NET Core的OpenID Connect和OAuth 2.0框架. 将 ...
随机推荐
- Oracle DECODE函数的语法介绍
Oracle DECODE函数功能很强,下面就为您详细介绍Oracle DECODE函数的用法,希望可以让您对Oracle DECODE函数有更多的了解. Oracle DECODE函数 Oracle ...
- 设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得该Account 对象能够自动分配id。 给定一个List 如下:
package homework005; public class Account { private long id; private double balance; private String ...
- linux快速入门 1.1命令行操作
http://lovesoo.org/linux-command-line-operation.html 1.1命令行操作 目录: <wp_nokeywordlink>Shell简介 &l ...
- <meta 标签的详细使用
meta是用来在HTML文档中模拟HTTP协议的响应头报文.meta 标签用于网页的<head>与</head>中,meta 标签的用处很多.meta 的属性有两种:na ...
- Redis实战之Redis + Jedis
用Memcached,对于缓存对象大小有要求,单个对象不得大于1MB,且不支持复杂的数据类型,譬如SET 等.基于这些限制,有必要考虑Redis! 相关链接: Redis实战 Redis实战之Redi ...
- 解读BOM与COM
概念: 1.BOM(Browser Object Model): 浏览器对象模型,从名字上就能知道它和浏览器关系密切. 浏览器的非常多行为是通过JavaScript控制的.比如打开新窗体.打开关闭标签 ...
- thinPHP中多维数组的遍历
$drug=array( 'ACEI'=>array(array('ch_name'=>'卡托普利','en_name'=>'captopril'),array('ch_nam ...
- HDU 5074 Hatsune Miku(DP)
Problem Description Hatsune Miku is a popular virtual singer. It is very popular in both Japan and C ...
- 2015北京网络赛 A题 The Cats' Feeding Spots 暴力
The Cats' Feeding Spots Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acm ...
- linux tomca几个配置文件及点
--------------------推荐----配置2---------------------<Connector port="8081"executor=" ...