Skip to content

Commit

Permalink
放弃所有标记为不再使用的代码,为新版本扫干净道路
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Feb 13, 2016
1 parent 6a84228 commit 8f770dd
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 374 deletions.
18 changes: 9 additions & 9 deletions NewLife.Net/DNS/DNSOpcodeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public enum DNSOpcodeType : byte
Status = 2,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd3 = 3,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd4 = 4,

/// <summary>NetBIOS registration</summary>
Expand All @@ -38,31 +38,31 @@ public enum DNSOpcodeType : byte
Refresh = 8,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd9 = 9,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd10 = 10,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd11 = 11,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd12 = 12,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd13 = 13,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd14 = 14,

/// <summary>Reserved for future use</summary>
[Obsolete("Reserved for future use.")]
//[Obsolete("Reserved for future use.")]
Reserverd15 = 15
}
}
40 changes: 20 additions & 20 deletions XCode/Configuration/FieldItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@ public Expression Contains(String value)
return CreateLike("%{0}%".F(value));
}

/// <summary>In操作。直接使用字符串可能有注入风险</summary>
/// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接</remarks>
/// <param name="value">逗号分割的数据。可能有注入风险</param>
/// <returns></returns>
[Obsolete("=>In(IEnumerable value),直接使用字符串参数可能有注入风险")]
public Expression In(String value)
{
if (String.IsNullOrEmpty(value)) return new Expression();
///// <summary>In操作。直接使用字符串可能有注入风险</summary>
///// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接</remarks>
///// <param name="value">逗号分割的数据。可能有注入风险</param>
///// <returns></returns>
//[Obsolete("=>In(IEnumerable value),直接使用字符串参数可能有注入风险")]
//public Expression In(String value)
//{
// if (String.IsNullOrEmpty(value)) return new Expression();

return CreateFormatExpression("{0} In({1})", Factory.FormatValue(this, value));
}
// return CreateFormatExpression("{0} In({1})", Factory.FormatValue(this, value));
//}

/// <summary>In操作</summary>
/// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接。只有一项时转为等于</remarks>
Expand Down Expand Up @@ -399,17 +399,17 @@ Expression _In(IEnumerable value, Boolean flag)
return CreateFormatExpression(flag ? "{0} In({1})" : "{0} Not In({1})", list.Join(","));
}

/// <summary>NotIn操作。直接使用字符串可能有注入风险</summary>
/// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接</remarks>
/// <param name="value">数值</param>
/// <returns></returns>
[Obsolete("=>NotIn(IEnumerable value),直接使用字符串参数可能有注入风险")]
public Expression NotIn(String value)
{
if (String.IsNullOrEmpty(value)) return new Expression();
///// <summary>NotIn操作。直接使用字符串可能有注入风险</summary>
///// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接</remarks>
///// <param name="value">数值</param>
///// <returns></returns>
//[Obsolete("=>NotIn(IEnumerable value),直接使用字符串参数可能有注入风险")]
//public Expression NotIn(String value)
//{
// if (String.IsNullOrEmpty(value)) return new Expression();

return CreateFormatExpression("{0} Not In({1})", Factory.FormatValue(this, value));
}
// return CreateFormatExpression("{0} Not In({1})", Factory.FormatValue(this, value));
//}

/// <summary>NotIn操作</summary>
/// <remarks>空参数不参与表达式操作,不生成该部分SQL拼接。只有一项时修改为不等于</remarks>
Expand Down
10 changes: 5 additions & 5 deletions XCode/DataAccessLayer/DAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ public void CheckTables()
}
}

/// <summary>在当前连接上检查指定数据表的架构</summary>
/// <param name="tables"></param>
[Obsolete("=>SetTables(set, tables)")]
[EditorBrowsable(EditorBrowsableState.Never)]
public void SetTables(params IDataTable[] tables) { SetTables(null, tables); }
///// <summary>在当前连接上检查指定数据表的架构</summary>
///// <param name="tables"></param>
//[Obsolete("=>SetTables(set, tables)")]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public void SetTables(params IDataTable[] tables) { SetTables(null, tables); }

/// <summary>在当前连接上检查指定数据表的架构</summary>
/// <param name="set"></param>
Expand Down
49 changes: 0 additions & 49 deletions XCode/DataAccessLayer/DAL_DbOperate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,6 @@ public Boolean EnableCache
#endregion

#region 使用缓存后的数据操作方法
private DictionaryCache<String, String> _PageSplitCache;
/// <summary>根据条件把普通查询SQL格式化为分页SQL。</summary>
/// <remarks>
/// 因为需要继承重写的原因,在数据类中并不方便缓存分页SQL。
/// 所以在这里做缓存。
/// </remarks>
/// <param name="sql">SQL语句</param>
/// <param name="startRowIndex">开始行,0表示第一行</param>
/// <param name="maximumRows">最大返回行数,0表示所有行</param>
/// <param name="keyColumn">唯一键。用于not in分页</param>
/// <returns>分页SQL</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("请优先考虑使用SelectBuilder参数做分页!")]
public String PageSplit(String sql, Int32 startRowIndex, Int32 maximumRows, String keyColumn)
{
var cacheKey = String.Format("{0}_{1}_{2}_{3}_{4}", sql, startRowIndex, maximumRows, keyColumn, ConnName);

// 一个项目可能同时采用多种数据库,分页缓存不能采用静态
if (_PageSplitCache == null) _PageSplitCache = new DictionaryCache<String, String>(StringComparer.OrdinalIgnoreCase);
return _PageSplitCache.GetItem(cacheKey, sql, startRowIndex, maximumRows, keyColumn, (k, b, s, m, kc) => Db.PageSplit(b, s, m, kc));
}

private DictionaryCache<String, SelectBuilder> _PageSplitCache2;
/// <summary>根据条件把普通查询SQL格式化为分页SQL。</summary>
/// <remarks>
Expand Down Expand Up @@ -124,33 +102,6 @@ public DataSet Select(SelectBuilder builder, Int32 startRowIndex, Int32 maximumR
return Select(builder.ToString(), tableNames);
}

/// <summary>执行SQL查询,返回总记录数</summary>
/// <param name="sql">SQL语句</param>
/// <param name="tableNames">所依赖的表的表名</param>
/// <returns></returns>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("请优先考虑使用SelectBuilder参数做查询!")]
public Int32 SelectCount(String sql, params String[] tableNames)
{
CheckBeforeUseDatabase();

var cacheKey = "";
var rs = 0;
if (EnableCache)
{
cacheKey = sql + "_SelectCount" + "_" + ConnName;
if (XCache.TryGetItem(cacheKey, out rs)) return rs;
}

Interlocked.Increment(ref _QueryTimes);
// 为了向前兼容,这里转为Int32,如果需要获取Int64,可直接调用Session
rs = (Int32)Session.QueryCount(sql);

if (EnableCache) XCache.Add(cacheKey, rs, tableNames);

return rs;
}

/// <summary>执行SQL查询,返回总记录数</summary>
/// <param name="sb">查询生成器</param>
/// <param name="tableNames">所依赖的表的表名</param>
Expand Down
24 changes: 12 additions & 12 deletions XCode/DataAccessLayer/MetaData/DbMetaData_Negative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ partial class DbMetaData
#endregion

#region 反向工程
/// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
/// <param name="tables"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("请改用多参数版本!")]
public void SetTables(params IDataTable[] tables)
{
//var set = new NegativeSetting();
//set.CheckOnly = DAL.NegativeCheckOnly;
//set.NoDelete = DAL.NegativeNoDelete;
var set = Setting.Current.Negative;
OnSetTables(tables, set);
}
///// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
///// <param name="tables"></param>
//[EditorBrowsable(EditorBrowsableState.Never)]
//[Obsolete("请改用多参数版本!")]
//public void SetTables(params IDataTable[] tables)
//{
// //var set = new NegativeSetting();
// //set.CheckOnly = DAL.NegativeCheckOnly;
// //set.NoDelete = DAL.NegativeNoDelete;
// var set = Setting.Current.Negative;
// OnSetTables(tables, set);
//}

/// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
/// <param name="setting">设置</param>
Expand Down
10 changes: 5 additions & 5 deletions XCode/DataAccessLayer/MetaData/IMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public interface IMetaData : IDisposable2
/// <returns></returns>
List<IDataTable> GetTables();

/// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
/// <param name="tables"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("请改用多参数版本!")]
void SetTables(params IDataTable[] tables);
///// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
///// <param name="tables"></param>
//[EditorBrowsable(EditorBrowsableState.Never)]
//[Obsolete("请改用多参数版本!")]
//void SetTables(params IDataTable[] tables);

/// <summary>设置表模型,检查数据表是否匹配表模型,反向工程</summary>
/// <param name="setting">设置</param>
Expand Down
96 changes: 48 additions & 48 deletions XCode/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -841,31 +841,31 @@ public static EntityList<TEntity> FindAllByName(String name, Object value, Strin
//[EditorBrowsable(EditorBrowsableState.Never)]
//public static EntityList<TEntity> FindAll(String sql) { return LoadData(Meta.Session.Query(sql)); }

/// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
/// <param name="whereClause">条件,不带Where</param>
/// <param name="orderClause">排序,不带Order By</param>
/// <param name="selects">查询列</param>
/// <param name="startRowIndex">开始行,0表示第一行</param>
/// <param name="maximumRows">最大返回行数,0表示所有行</param>
/// <param name="count">记录总数</param>
/// <param name="mode">查询模式,分为记录集和记录总数两种,默认Both表示同时查询两者</param>
/// <returns>实体集</returns>
[Obsolete("=>FindAll(String whereClause, PageParameter param)")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static EntityList<TEntity> FindAll(String whereClause, String orderClause, String selects, Int32 startRowIndex, Int32 maximumRows, out Int32 count, SelectModes mode = SelectModes.Both)
{
count = 0;
///// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
///// <param name="whereClause">条件,不带Where</param>
///// <param name="orderClause">排序,不带Order By</param>
///// <param name="selects">查询列</param>
///// <param name="startRowIndex">开始行,0表示第一行</param>
///// <param name="maximumRows">最大返回行数,0表示所有行</param>
///// <param name="count">记录总数</param>
///// <param name="mode">查询模式,分为记录集和记录总数两种,默认Both表示同时查询两者</param>
///// <returns>实体集</returns>
//[Obsolete("=>FindAll(String whereClause, PageParameter param)")]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public static EntityList<TEntity> FindAll(String whereClause, String orderClause, String selects, Int32 startRowIndex, Int32 maximumRows, out Int32 count, SelectModes mode = SelectModes.Both)
//{
// count = 0;

if (mode.Has(SelectModes.TotalCount))
{
count = FindCount(whereClause, null, null, 0, 0);
if (mode == SelectModes.TotalCount) return null;
// if (mode.Has(SelectModes.TotalCount))
// {
// count = FindCount(whereClause, null, null, 0, 0);
// if (mode == SelectModes.TotalCount) return null;

if (count <= 0) return new EntityList<TEntity>();
}
// if (count <= 0) return new EntityList<TEntity>();
// }

return FindAll(whereClause, orderClause, selects, startRowIndex, maximumRows);
}
// return FindAll(whereClause, orderClause, selects, startRowIndex, maximumRows);
//}

/// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
/// <param name="whereClause">条件,不带Where</param>
Expand Down Expand Up @@ -1019,31 +1019,31 @@ public static SelectBuilder FindSQLWithKey(String whereClause = null)
/// <returns>记录数</returns>
public static Int32 SearchCount(String key, String orderClause, Int32 startRowIndex, Int32 maximumRows) { return FindCount(SearchWhereByKeys(key, null), null, null, 0, 0); }

/// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
/// <param name="key"></param>
/// <param name="orderClause"></param>
/// <param name="startRowIndex"></param>
/// <param name="maximumRows"></param>
/// <param name="count"></param>
/// <param name="mode"></param>
/// <returns></returns>
[Obsolete("=>Search(String key, PageParameter param)")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static EntityList<TEntity> Search(String key, String orderClause, Int32 startRowIndex, Int32 maximumRows, out Int32 count, SelectModes mode = SelectModes.Both)
{
count = 0;
var where = SearchWhereByKeys(key, null);
///// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
///// <param name="key"></param>
///// <param name="orderClause"></param>
///// <param name="startRowIndex"></param>
///// <param name="maximumRows"></param>
///// <param name="count"></param>
///// <param name="mode"></param>
///// <returns></returns>
//[Obsolete("=>Search(String key, PageParameter param)")]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public static EntityList<TEntity> Search(String key, String orderClause, Int32 startRowIndex, Int32 maximumRows, out Int32 count, SelectModes mode = SelectModes.Both)
//{
// count = 0;
// var where = SearchWhereByKeys(key, null);

if (mode.Has(SelectModes.TotalCount))
{
count = FindCount(where, null, null, 0, 0);
if (mode == SelectModes.TotalCount) return null;
// if (mode.Has(SelectModes.TotalCount))
// {
// count = FindCount(where, null, null, 0, 0);
// if (mode == SelectModes.TotalCount) return null;

if (count <= 0) return new EntityList<TEntity>();
}
// if (count <= 0) return new EntityList<TEntity>();
// }

return FindAll(SearchWhereByKeys(key, null), orderClause, null, startRowIndex, maximumRows);
}
// return FindAll(SearchWhereByKeys(key, null), orderClause, null, startRowIndex, maximumRows);
//}

/// <summary>同时查询满足条件的记录集和记录总数。没有数据时返回空集合而不是null</summary>
/// <param name="key"></param>
Expand Down Expand Up @@ -1480,10 +1480,10 @@ public override string ToString()
return "实体" + Meta.ThisType.Name;
}

/// <summary>默认累加字段</summary>
[Obsolete("=>IEntityOperate")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static ICollection<String> AdditionalFields { get { return Meta.Factory.AdditionalFields; } }
///// <summary>默认累加字段</summary>
//[Obsolete("=>IEntityOperate")]
//[EditorBrowsable(EditorBrowsableState.Never)]
//public static ICollection<String> AdditionalFields { get { return Meta.Factory.AdditionalFields; } }
#endregion

#region 脏数据
Expand Down
8 changes: 4 additions & 4 deletions XCode/Entity/EntityList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -948,10 +948,10 @@ IList IListSource.GetList()
#endregion

#region 辅助函数
private static EntityList<T> _Empty;
/// <summary>空集合</summary>
[Obsolete("该属性容易让人误操作,比如给空列表加入元素!")]
public static EntityList<T> Empty { get { return _Empty ?? (_Empty = new EntityList<T>()); } }
//private static EntityList<T> _Empty;
///// <summary>空集合</summary>
//[Obsolete("该属性容易让人误操作,比如给空列表加入元素!")]
//public static EntityList<T> Empty { get { return _Empty ?? (_Empty = new EntityList<T>()); } }

/// <summary>真正的实体类型。有些场合为了需要会使用IEntity。</summary>
Type EntityType
Expand Down
Loading

0 comments on commit 8f770dd

Please sign in to comment.