CTL.Data/SqlDB.cs
(开头部分) 14KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace CTL.Data
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
public class SqlDB<T> where T : SqlDB<T>, new()
{
private static T _instance;
private static object _lockHelper;
static SqlDB()
{
SqlDB<T>._instance = default(T);
SqlDB<T>._lockHelper = new object();
}
public static T GetInstance()
{
if (SqlDB<T>._instance == null)
{
lock (SqlDB<T>._lockHelper)
{
if (SqlDB<T>._instance == null)
{
SqlDB<T>._instance = Activator.CreateInstance<T>();
}
}
}
return SqlDB<T>._instance;
}
/// <summary>
/// 存放表的字段
/// </summary>
List<string> Colums = new List<string>();
/// <summary>
/// 获取总数
/// </summary>
/// <param name="tableName">表名或视图名</param>
/// <param name="condition">条件</param>
/// <returns></returns>
public int GetCount(string tableName, string condition)
{
if (condition == "") condition = "1=1";
return (int)SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM " + tableName + " WHERE " + condition);
}
/// <summary>
/// 获取总数,判断是否存在
/// </summary>
/// <param name="tableName">表名或视图名</param>
/// <param name="condition">条件</param>
/// <returns></returns>
public bool Exist(string tableName, string condition)
{
后面还有 316 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。