也不是全不能上,房间里有三台能上网的机子(两台笔记本+一台台式机),下载资料还得用公司的U盘再转到自己电脑,这种半封闭的环境,相当的让人不适应,有种欲仰天吐血的感觉。
经过一周的研究,我发现解决方案还是有的:因为公司的规定只是开发的机子不让上网而已,自己按理应该可以带笔记本去上网,不过我奇怪的是竟然整个部门都没人带笔记本去,不知道搞啥名头。
using System;
using System.Collections.Generic;
using System.Text;
using CYQ.Data.Table;
namespace CYQ.Data.Orm
{
/// <summary>
/// 快速操作操作类。
/// </summary>
public static class DBFast
{
/// <summary>
/// 查找单条记录
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="where">条件</param>
/// <param name="columns">指定查询的列(可选)</param>
/// <returns></returns>
public static T Find<T>(object where, params string[] columns)
{
T result = default(T);
MDataRow row = null;
using (MAction action = GetMAction<T>())
{
if (columns != null && columns.Length > 0)
{
action.SetSelectColumns(columns);
}
if (action.Fill(where))
{
row = action.Data;
}
}
if (row != null)
{
result = row.ToEntity<T>();
}
return result;
}
public static List<T> Select<T>()
{
int count;
return Select<T>(0, 0, null, out count, null);
}
/// <summary>
/// 列表查询
/// </summary>
/// <param name="where">查询条件[可附带 order by 语句]</param>
/// <returns></returns>
public static List<T> Select<T>(string where, params string[] columns)
{
int count;
return Select<T>(0, 0, where, out count, columns);
}
/// <summary>
/// 列表查询
/// </summary>
/// <param name="topN">查询几条</param>
/// <param name="where">查询条件[可附带 order by 语句]</param>
/// <returns></returns>
public static List<T> Select<T>(int topN, string where, params string[] columns)
{
int count;
return Select<T>(1, topN, where, out count, columns);
}
public static List<T> Select<T>(int pageIndex, int pageSize, params string[] columns)
{
int count;
return Select<T>(pageIndex, pageSize, null, out count, columns);
}
public static List<T> Select<T>(int pageIndex, int pageSize, string where, params string[] columns)
{
int count;
return Select<T>(pageIndex, pageSize, where, out count, columns);
}
/// <summary>
/// 查找多条记录
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="pageIndex">第N页</param>
/// <param name="pageSize">每页N条</param>
/// <param name="where">条件</param>
/// <param name="count">返回记录总数</param>
/// <param name="columns">指定查询的列(可选)</param>
/// <returns></returns>
public static List<T> Select<T>(int pageIndex, int pageSize, object where, out int count, params string[] columns)
{
MDataTable dt = null;
using (MAction action = GetMAction<T>())
{
if (columns != null && columns.Length > 0)
{
action.SetSelectColumns(columns);
}
dt = action.Select(pageIndex, pageSize, where, out count);
}
return dt.ToList<T>();
}
/// <summary>
/// 删除记录
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="where">条件</param>
/// <returns></returns>
public static bool Delete<T>(object where)
{
bool result = false;
using (MAction action = GetMAction<T>())
{
result = action.Delete(where);
}
return result;
}
public static bool Insert<T>(T t)
{
return Insert<T>(t, InsertOp.ID);
}
/// <summary>
/// 添加一条记录
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="t">实体对象</param>
/// <returns></returns>
public static bool Insert<T>(T t, InsertOp op)
{
bool result = false;
MDataRow row = null;
using (MAction action = GetMAction<T>())
{
action.Data.SetFromEntity(t);
result = action.Insert(op);
if (op != InsertOp.None)
{
row = action.Data;
}
}
if (row != null)
{
row.SetToEntity(t);
}
return result;
}
public static bool Update<T>(T t)
{
return Update<T>(t, null);
}
/// <summary>
/// 更新记录
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
/// <param name="t">实体对象</param>
/// <param name="where">条件</param>
/// <returns></returns>
public static bool Update<T>(T t, object where)
{
bool result = false;
using (MAction action = GetMAction<T>())
{
action.Data.SetFromEntity(t);
result = action.Update(where);
}
return result;
}
private static MAction GetMAction<T>()
{
string conn = string.Empty;
MAction action = new MAction(GetTableName<T>(out conn), conn);
action.SetNoAop();
return action;
}
private static string GetTableName<T>(out string conn)
{
conn = string.Empty;
Type t = typeof(T);
string[] items = t.FullName.Split(‘.‘);
if (items.Length > 1)
{
conn = items[items.Length - 2] + "Conn";
items = null;
}
string tName = t.Name;
t = null;
return tName;
}
}
}
新进的公司,一开始以为是开发电子商务类的网站,所以我经三考虑的架构选型不是WebForm也不是MVC,而是打算采用QBlog那一套的框架,还特意思改进了CYQ.Data里的XHtmlAction模板引擎,增加了CMS的标签功能,以为要上战场,结果进去一天就发现,是开发的分销商订单系统,数据是和ERP对接,于是架构目前选型就变更为EasyUI+CYQ.Data+WebForm了。