- 下载代码生成器
/Files/humble/Moon.ORM-3.6.zip - 配置大码生成器的配置文件.http://www.mysql.com/downloads/mirror.php?id=406542 mysql 2.0下载地址
- 通过代码生成器,生成你系统数据库中所有的实体.(编译Mode,然后在C盘找到 MoonDB.CS 或者 MoonDB.DLL,引入dll或者文件到你实际的项目)
开始编码
/*
*/
using System;
using System.Collections.Generic;
using System.Data;
using Moon.Orm;
using MoonDB;
namespace r
{
class Program
{
public static void Main(string[] args)
{
//------------------------
Console.WriteLine("1 排序操作--------");
List<UserSet> list=DBFactory.GetEntities<UserSet>(
UserSetTable.ID.BiggerThan(0).OrderBy(UserSetTable.UserName,true));
foreach (UserSet element in list) {
Console.WriteLine(element.UserName+" "+element.ID);
}
//-----------------------------------
Console.WriteLine("2 添加操作------");
UserSet user=new UserSet();
user.date=DateTime.Now;
user.datetime=DateTime.Now;
user.money=123M;
user.UserName="秦时明月";
object newID=DBFactory.Add(user);
Console.WriteLine("新增数据的主键为:"+newID);
//-----------------------------
Console.WriteLine("3 修改操作------");
UserSet updateUser=new UserSet();
updateUser.UserName="秦时明月-updateUser";
//设置更新目标
updateUser.SetOnlyMark(user.GetOnlyMark());
DBFactory.Update(updateUser);
Console.WriteLine("被修改的对象:"+updateUser.GetOnlyMark());
Console.WriteLine("修改后的对象值为:");
string name=DBFactory.GetOneField<string>(UserSetTable.UserName ,updateUser.GetOnlyMark());
Console.WriteLine(name);
Console.Read();
}
}
}
*/
using System;
using System.Collections.Generic;
using System.Data;
using Moon.Orm;
using MoonDB;
namespace r
{
class Program
{
public static void Main(string[] args)
{
//------------------------
Console.WriteLine("1 排序操作--------");
List<UserSet> list=DBFactory.GetEntities<UserSet>(
UserSetTable.ID.BiggerThan(0).OrderBy(UserSetTable.UserName,true));
foreach (UserSet element in list) {
Console.WriteLine(element.UserName+" "+element.ID);
}
//-----------------------------------
Console.WriteLine("2 添加操作------");
UserSet user=new UserSet();
user.date=DateTime.Now;
user.datetime=DateTime.Now;
user.money=123M;
user.UserName="秦时明月";
object newID=DBFactory.Add(user);
Console.WriteLine("新增数据的主键为:"+newID);
//-----------------------------
Console.WriteLine("3 修改操作------");
UserSet updateUser=new UserSet();
updateUser.UserName="秦时明月-updateUser";
//设置更新目标
updateUser.SetOnlyMark(user.GetOnlyMark());
DBFactory.Update(updateUser);
Console.WriteLine("被修改的对象:"+updateUser.GetOnlyMark());
Console.WriteLine("修改后的对象值为:");
string name=DBFactory.GetOneField<string>(UserSetTable.UserName ,updateUser.GetOnlyMark());
Console.WriteLine(name);
Console.Read();
}
}
}
QQ群技术交流:
216965349