/// <summary> /// 释放对象占用的所有资源。 /// </summary> public virtual void Dispose() { _tableName = null; _removedFields?.Clear(); _removedFields = null; _fields?.Clear(); _fields = null; _dataContext = null; }
/// <summary> /// 创建InsertCommandBuilder实例。 /// </summary> /// <param name="dataContext">数据上下文接口。</param> /// <param name="tableName">表名。</param> public UpdateCommandBuilder(IDataContext dataContext, string tableName) { _dataContext = dataContext; dataContext.DisposableObjects?.Add(this); _tableName = tableName; _removedFields = new Collections.Generic.HashSet <string>(System.StringComparer.OrdinalIgnoreCase); _fields = new Collections.Generic.NameValueCollection <object>(); _fields.NullValue = System.DBNull.Value; _fields.PropertyDescriptor = FieldValueWrapper; }
static SQLiteHelper() { _isDebug = new bool[] { false }; _inited = new bool[] { false }; _assemblies = new System.Reflection.Assembly[1]; _types = new Collections.Generic.NameValueCollection <FastWrapper>(); _typeNames = new Collections.Generic.HashSet <string>(); LoadAssembly(typeof(System.Data.SQLite.SQLiteConnection).Assembly); }
/// <summary> /// 将可遍历枚举转换为HashSet<T>对象。 /// </summary> /// <typeparam name="T">任意类型。</typeparam> /// <param name="source">可遍历枚举。</param> /// <param name="predicate">筛选规则。</param> /// <returns>返回一个HashSet<T>对象。</returns> public static Symbol.Collections.Generic.HashSet <T> ToHashSet <T>( #if !net20 this #endif IEnumerable <T> source, Predicate <T> predicate) { Symbol.CommonException.CheckArgumentNull(source, "source"); Symbol.Collections.Generic.HashSet <T> result = new Symbol.Collections.Generic.HashSet <T>(); foreach (T item in source) { if (predicate == null || predicate(item)) { result.Add(item); } } return(result); }
/// <summary> /// 创建SelectCommandBuilder实例。 /// </summary> /// <param name="dataContext">数据上下文接口。</param> /// <param name="tableName">表名,如果commandText有值,将忽略此参数。</param> /// <param name="commandText">命令脚本。</param> public SelectCommandBuilder(IDataContext dataContext, string tableName, string commandText) { _dataContext = dataContext; dataContext.DisposableObjects?.Add(this); _tableName = tableName; _fields = new Collections.Generic.HashSet <string>(System.StringComparer.OrdinalIgnoreCase); _whereBefores = new Collections.Generic.HashSet <string>(System.StringComparer.OrdinalIgnoreCase); _orderbys = new Collections.Generic.HashSet <string>(System.StringComparer.OrdinalIgnoreCase); TakeCount = -1; _parameters = new System.Collections.Generic.List <object>(); _dialect = dataContext.Provider.CreateDialect(); _whereExpression = CreateWhereExpression(); _whereExpression.AddCommandParameter = AddCommandParameterDefault; if (!string.IsNullOrEmpty(commandText)) { Parse(commandText); } _dialect.Keywords.Add("$self", _tableName); }
/// <summary> /// 解析key/value。 /// </summary> /// <param name="values">包含key/value的文本</param> /// <param name="needDecode">是否需要解码</param> /// <param name="separator">分割符</param> public void ParseValues(string values, bool needDecode, params string[] separator) { if (separator == null || separator.Length == 0) { CommonException.ThrowArgumentNull("separator"); } if (string.IsNullOrEmpty(values)) { return; } if (values.StartsWith("?")) { values = values.Substring(1); } var keys = new Symbol.Collections.Generic.HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (string item in values.Split(separator, StringSplitOptions.None)) { string key = string.Empty; string value = string.Empty; if (item.IndexOf('=') == -1) { value = item; } else { string[] array = item.Split('='); key = array[0]; value = array[1]; } if (keys.Add(key)) { this.Remove(key); } Add(key, needDecode ? HttpUtility.UrlDecode(value, Encoding) : value); } }
/// <summary> /// 释放对象占用的所有资源。 /// </summary> public virtual void Dispose() { if (AutoEnd) { OnEnd(); } _tableName = null; _fields?.Clear(); _fields = null; _whereBefores?.Clear(); _whereBefores = null; _whereExpression?.Clear(); _whereExpression?.Dispose(); _whereExpression = null; _orderbys?.Clear(); _orderbys = null; _dataContext = null; _parameters?.Clear(); _parameters = null; _dialect = null; }