Hotel/Common/DbUtils.cs
(开头部分) 22KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Omu.ValueInjecter;
using System.Configuration;
using Common.Data.SqlServer;
using Common.Data;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Transactions;
using System.Reflection;
namespace Common
{
public static class DbUtils
{
static string cs = SqlEasy.connString; //資料庫連接字串
public static IEnumerable<T> GetWhere<T>(object where) where T : new()
{
using (var conn = new SqlConnection(cs))
{
using (var cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from " + TableConvention.Resolve(typeof(T)) + " where "
.InjectFrom(new FieldsBy()
.SetFormat("{0}=@{0}")
.SetNullFormat("{0} is null")
.SetGlue("and"),
where);
cmd.InjectFrom<SetParamsValues>(where);
conn.Open();
using (var dr = cmd.ExecuteReader())
{
while (dr.Read())
{
var o = new T();
o.InjectFrom<ReaderInjection>(dr);
yield return o;
}
}
}
}
}
public static int CountWhere<T>(object where) where T : new()
{
using (var conn = new SqlConnection(cs))
{
using (var cmd = conn.CreateCommand())
后面还有 593 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。