好久没更新了,
从原来的只有那么一点点时间到了,
变成了只剩下想法,和文档了。
满满的都是意见。
看得连自己都头疼。
好久没更新什么东西了,
一直很忙,
从原来的只有那么一点点时间到了,
变成了只剩下想法,和文档了。
满满的都是意见。
看得连自己都头疼。
近来好几个项目都转成mssql了,其实应该不是access的问题,
自己程序不够好吧,其实也就几十万的数据量而已,
改,当然是要的,不过还是以后再说吧。
什么把我变懒惰的?不知道呢^_^
闷得很,还是贴点东西吧:
1. 以后再也不建任何含有自动增长的数据表了,
既然每一条数据都很重要,它的序号、它的唯一标识自然更重要咯。
2. sqlquery还是少了几句话, 加上:
Code
public static int Insert(DB db, TianvBlog info)
{
if(info.Id==0)
{
SqlQuery getMaxId = new SqlQuery()
.Select(TianvBlogQuery.Id.Max)
.From(TianvBlogQuery.Table);
int maxId = db.ExecuteScalar<int>(getMaxId);
info.Id = maxId + 1;
}
SqlQuery insert = new SqlQuery()
.Insert(TianvBlogQuery.Table)
.Parameter(TianvBlogQuery.Id, info.Id)
.Parameter(TianvBlogQuery.UserId, info.UserId)
.Parameter(TianvBlogQuery.SystemCategoryId, info.SystemCategoryId)
.Parameter(TianvBlogQuery.CategoryId, info.CategoryId)
.Parameter(TianvBlogQuery.Picture, info.Picture)
.Parameter(TianvBlogQuery.Title, info.Title)
.Parameter(TianvBlogQuery.Synopsis, info.Synopsis)
.Parameter(TianvBlogQuery.Content, info.Content)
.Parameter(TianvBlogQuery.Tag, info.Tag)
.Parameter(TianvBlogQuery.Flag, info.Flag)
.Parameter(TianvBlogQuery.AllowUserId, info.AllowUserId)
.Parameter(TianvBlogQuery.IpAddress, info.IpAddress)
.Parameter(TianvBlogQuery.tCreate, info.tCreate)
.Parameter(TianvBlogQuery.tUpdate, info.tUpdate)
.Parameter(TianvBlogQuery.iReply, info.iReply)
.Parameter(TianvBlogQuery.iView, info.iView)
.Parameter(TianvBlogQuery.iMsg, info.iMsg)
.Parameter(TianvBlogQuery.iTrace, info.iTrace)
.Parameter(TianvBlogQuery.iTrackBack, info.iTrackBack)
.Parameter(TianvBlogQuery.iOrder, info.iOrder)
.Parameter(TianvBlogQuery.bReply, info.bReply)
;
int result = db.ExecuteNonQuery(insert);
return info.Id;
}
#endregion
public static int Insert(DB db, TianvBlog info)
{
if(info.Id==0)
{
SqlQuery getMaxId = new SqlQuery()
.Select(TianvBlogQuery.Id.Max)
.From(TianvBlogQuery.Table);
int maxId = db.ExecuteScalar<int>(getMaxId);
info.Id = maxId + 1;
}
SqlQuery insert = new SqlQuery()
.Insert(TianvBlogQuery.Table)
.Parameter(TianvBlogQuery.Id, info.Id)
.Parameter(TianvBlogQuery.UserId, info.UserId)
.Parameter(TianvBlogQuery.SystemCategoryId, info.SystemCategoryId)
.Parameter(TianvBlogQuery.CategoryId, info.CategoryId)
.Parameter(TianvBlogQuery.Picture, info.Picture)
.Parameter(TianvBlogQuery.Title, info.Title)
.Parameter(TianvBlogQuery.Synopsis, info.Synopsis)
.Parameter(TianvBlogQuery.Content, info.Content)
.Parameter(TianvBlogQuery.Tag, info.Tag)
.Parameter(TianvBlogQuery.Flag, info.Flag)
.Parameter(TianvBlogQuery.AllowUserId, info.AllowUserId)
.Parameter(TianvBlogQuery.IpAddress, info.IpAddress)
.Parameter(TianvBlogQuery.tCreate, info.tCreate)
.Parameter(TianvBlogQuery.tUpdate, info.tUpdate)
.Parameter(TianvBlogQuery.iReply, info.iReply)
.Parameter(TianvBlogQuery.iView, info.iView)
.Parameter(TianvBlogQuery.iMsg, info.iMsg)
.Parameter(TianvBlogQuery.iTrace, info.iTrace)
.Parameter(TianvBlogQuery.iTrackBack, info.iTrackBack)
.Parameter(TianvBlogQuery.iOrder, info.iOrder)
.Parameter(TianvBlogQuery.bReply, info.bReply)
;
int result = db.ExecuteNonQuery(insert);
return info.Id;
}
#endregion
Code
public static int Update(DB db, TianvBlog info)
{
SqlQuery update = new SqlQuery()
.Update(TianvBlogQuery.Table)
.Set(TianvBlogQuery.UserId, info.UserId)
.Set(TianvBlogQuery.SystemCategoryId, info.SystemCategoryId)
.Set(TianvBlogQuery.CategoryId, info.CategoryId)
.Set(TianvBlogQuery.Picture, info.Picture)
.Set(TianvBlogQuery.Title, info.Title)
.Set(TianvBlogQuery.Synopsis, info.Synopsis)
.Set(TianvBlogQuery.Content, info.Content)
.Set(TianvBlogQuery.Tag, info.Tag)
.Set(TianvBlogQuery.Flag, info.Flag)
.Set(TianvBlogQuery.AllowUserId, info.AllowUserId)
.Set(TianvBlogQuery.IpAddress, info.IpAddress)
.Set(TianvBlogQuery.tCreate, info.tCreate)
.Set(TianvBlogQuery.tUpdate, info.tUpdate)
.Set(TianvBlogQuery.iReply, info.iReply)
.Set(TianvBlogQuery.iView, info.iView)
.Set(TianvBlogQuery.iMsg, info.iMsg)
.Set(TianvBlogQuery.iTrace, info.iTrace)
.Set(TianvBlogQuery.iTrackBack, info.iTrackBack)
.Set(TianvBlogQuery.iOrder, info.iOrder)
.Set(TianvBlogQuery.bReply, info.bReply)
.Where(TianvBlogQuery.Id).IsEqualTo(info.Id);
return db.ExecuteNonQuery(update);
}
public static int Update(DB db, TianvBlog info)
{
SqlQuery update = new SqlQuery()
.Update(TianvBlogQuery.Table)
.Set(TianvBlogQuery.UserId, info.UserId)
.Set(TianvBlogQuery.SystemCategoryId, info.SystemCategoryId)
.Set(TianvBlogQuery.CategoryId, info.CategoryId)
.Set(TianvBlogQuery.Picture, info.Picture)
.Set(TianvBlogQuery.Title, info.Title)
.Set(TianvBlogQuery.Synopsis, info.Synopsis)
.Set(TianvBlogQuery.Content, info.Content)
.Set(TianvBlogQuery.Tag, info.Tag)
.Set(TianvBlogQuery.Flag, info.Flag)
.Set(TianvBlogQuery.AllowUserId, info.AllowUserId)
.Set(TianvBlogQuery.IpAddress, info.IpAddress)
.Set(TianvBlogQuery.tCreate, info.tCreate)
.Set(TianvBlogQuery.tUpdate, info.tUpdate)
.Set(TianvBlogQuery.iReply, info.iReply)
.Set(TianvBlogQuery.iView, info.iView)
.Set(TianvBlogQuery.iMsg, info.iMsg)
.Set(TianvBlogQuery.iTrace, info.iTrace)
.Set(TianvBlogQuery.iTrackBack, info.iTrackBack)
.Set(TianvBlogQuery.iOrder, info.iOrder)
.Set(TianvBlogQuery.bReply, info.bReply)
.Where(TianvBlogQuery.Id).IsEqualTo(info.Id);
return db.ExecuteNonQuery(update);
}