-
/// <summary>
/// Where的Str in/not in查询
/// </summary>
/// <param name="info">数据库表字段</param>
/// <param name="theValue">查询值</param>
public void WhereAddSqlIn
(
EntityFieldInfo info,
string theValue
)
{
if (theValue == null || theValue.Length == 0)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "传入的字符串参数:"
+ "string theValue"
+ "为null或为空。"
);
}
m_ListIQueryItem.Add
(
new DataColumnQuerySqlInItem
(
info,
theValue
)
);
}
/// <summary>
/// Where的Str in/not in查询
/// </summary>
/// <param name="info">数据库表字段</param>
/// <param name="isIn">in / not in</param>
/// <param name="theValue">查询值</param>
public void WhereAddSqlIn
(
EntityFieldInfo info,
bool isIn,
string theValue
)
{
if (theValue == null || theValue.Length == 0)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "传入的字符串参数:"
+ "string theValue"
+ "为null或为空。"
);
}
m_ListIQueryItem.Add
(
new DataColumnQuerySqlInItem
(
info,
isIn,
theValue
)
);
}
/// <summary>
/// Where的Str in/not in查询
/// </summary>
/// <param name="info">数据库表字段</param>
/// <param name="theValue">查询值</param>
public void WhereAddSqlNotIn
(
EntityFieldInfo info,
string theValue
)
{
if (theValue == null || theValue.Length == 0)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "传入的字符串参数:"
+ "string theValue"
+ "为null或为空。"
);
}
m_ListIQueryItem.Add
(
new DataColumnQuerySqlInItem
(
info,
false,
theValue
)
);
}
-
t.ID in (1,3,5,7,9)
-
#region TheSQLGet
/// <summary>
/// 获得输出的SQL语句
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected override string TheSQLGet(DBHelper xdbHelper)
{
#region 逻辑代码
string theResult = null;
// 标识是否创建或打开数据库链接 //
bool bIsCreate = true;
if (xdbHelper == null)
{
// 如果 xdbHelper 为null //
// 则new一个数据库操作实体 //
xdbHelper
=
SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
}
else
{
// 如果 xdbHelper 不为null //
// 判断 xdbHelper是否打开链接 //
// 相当于是否执行 xdbHelper.OpenDBHelper(); //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
{
// 没有打开,则打开链接 //
xdbHelper.OpenDBHelper();
}
// 业务逻辑操作实体 //
// insert/update/delete等操作 //
SlowX.ExamLib.Business.UTB_EXAM_COURSE
bll
=
SlowX.ExamLib.Business.UTB_EXAM_COURSE.instance;
// 组合SQL的逻辑实体 //
SlowX.ExamLib.Entity.UTB_EXAM_COURSE
entity
=
new SlowX.ExamLib.Entity.UTB_EXAM_COURSE();
IWhereDriver iwhere = entity;
string str = "1,3,5,7,9";
// ===调用代码=== //
iwhere.WhereAddSqlIn
(
entity._ID,
str
);
// 执行List操作 //
// 这里做DEMO,仅打印输出的SQL语句 //
// bll.List(entity, xdbHelper);
theResult
=
bll.i_iBuildSQL.BuildSqlList(entity, xdbHelper);
if (bIsCreate)
{
// 关闭数据库链接 //
// 如果用了事务,提交数据库链接 //
xdbHelper.EndDBHelper();
}
}
catch (Exception err)
{
if (bIsCreate)
{
// 关闭数据库链接 //
// 如果用了事务,回滚数据库链接 //
xdbHelper.TranDBHelper();
}
throw err;
}
finally
{
if (bIsCreate)
{
// 判断数据库操作是否正确关闭 //
// 如果没有正确关闭,则关闭并抛出异常提示代码缺陷 //
xdbHelper.FinallyDBHelper();
}
}
return theResult;
#endregion 逻辑代码
}
#endregion TheSQLGet
-
select
t.ID, t.TheName, t.CreateTime,
t.UpdateTime
from UTB_EXAM_COURSE t
where t.ID in (1,3,5,7,9)
select
t.ID, t.TheName, t.CreateTime,
t.UpdateTime
from UTB_EXAM_COURSE t
where t.ID in (1,3,5,7,9)