コード例 #1
0
        private DataTable GetCopyWriteDataTable(DataTable dt)
        {
            DataTable tempDataTable = ReflectionInoCore <DataTable> .GetInstance().GetOrCreate("BulkCopyAsync_dt" + dt.TableName,
                                                                                               () =>
            {
                if (AsName == null)
                {
                    return(queryable.Where(it => false).Select("*").ToDataTable());
                }
                else
                {
                    return(queryable.AS(AsName).Where(it => false).Select("*").ToDataTable());
                }
            }
                                                                                               );

            var temColumnsList = tempDataTable.Columns.Cast <DataColumn>().Select(it => it.ColumnName.ToLower()).ToList();
            var columns        = dt.Columns.Cast <DataColumn>().Where(it => temColumnsList.Contains(it.ColumnName.ToLower())).ToList();

            foreach (DataRow item in dt.Rows)
            {
                DataRow dr = tempDataTable.NewRow();
                foreach (DataColumn column in columns)
                {
                    dr[column.ColumnName] = item[column.ColumnName];
                    if (dr[column.ColumnName] == null)
                    {
                        dr[column.ColumnName] = DBNull.Value;
                    }
                }
                tempDataTable.Rows.Add(dr);
            }
            tempDataTable.TableName = dt.TableName;
            return(tempDataTable);
        }
コード例 #2
0
        private DataTable ToDdateTable(List <T> datas)
        {
            DataTable tempDataTable = ReflectionInoCore <DataTable> .GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName,
                                                                                               () =>
            {
                if (AsName == null)
                {
                    return(queryable.Where(it => false).Select("*").ToDataTable());
                }
                else
                {
                    return(queryable.AS(AsName).Where(it => false).Select("*").ToDataTable());
                }
            }
                                                                                               );

            var dt = new DataTable();

            foreach (DataColumn item in tempDataTable.Columns)
            {
                dt.Columns.Add(item.ColumnName, item.DataType);
            }
            dt.TableName = GetTableName();
            var columns = entityInfo.Columns;
            var isMySql = this.context.CurrentConnectionConfig.DbType.IsIn(DbType.MySql, DbType.MySqlConnector);

            foreach (var item in datas)
            {
                var dr = dt.NewRow();
                foreach (var column in columns)
                {
                    if (column.IsIgnore || column.IsOnlyIgnoreInsert)
                    {
                        continue;
                    }
                    var name = column.DbColumnName;
                    if (name == null)
                    {
                        name = column.PropertyName;
                    }
                    var value = ValueConverter(column, PropertyCallAdapterProvider <T> .GetInstance(column.PropertyName).InvokeGet(item));
                    if (isMySql && column.UnderType == UtilConstants.BoolType)
                    {
                        if (value.ObjToBool() == false)
                        {
                            value = DBNull.Value;
                        }
                    }
                    else if (column.UnderType == UtilConstants.DateTimeOffsetType && value != null)
                    {
                        value = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
                    }
                    dr[name] = value;
                }
                dt.Rows.Add(dr);
            }

            return(dt);
        }
コード例 #3
0
 public static ReflectionInoCore <V> GetInstance()
 {
     if (_instance == null)
     {
         lock (_instanceLock)
             if (_instance == null)
             {
                 _instance = new ReflectionInoCore <V>();
                 Action addItem = () => { ReflectionInoCore <V> .GetInstance().RemoveAllCache(); };
                 ReflectionInoHelper.AddRemoveFunc(addItem);
             }
     }
     return(_instance);
 }
コード例 #4
0
ファイル: Private.cs プロジェクト: Crazyleofeng/SqlSugar
        private DataTable ToDdateTable(List <T> datas)
        {
            DataTable tempDataTable = ReflectionInoCore <DataTable> .GetInstance().GetOrCreate("BulkCopyAsync" + typeof(T).FullName,
                                                                                               () =>
            {
                if (AsName == null)
                {
                    return(queryable.Where(it => false).Select("*").ToDataTable());
                }
                else
                {
                    return(queryable.AS(AsName).Where(it => false).Select("*").ToDataTable());
                }
            }
                                                                                               );

            var dt = new DataTable();

            foreach (DataColumn item in tempDataTable.Columns)
            {
                dt.Columns.Add(item.ColumnName, item.DataType);
            }
            dt.TableName = GetTableName();
            var columns = entityInfo.Columns;

            foreach (var item in datas)
            {
                var dr = dt.NewRow();
                foreach (var column in columns)
                {
                    if (column.IsIgnore || column.IsOnlyIgnoreInsert)
                    {
                        continue;
                    }
                    var name = column.DbColumnName;
                    if (name == null)
                    {
                        name = column.PropertyName;
                    }
                    var value = ValueConverter(column, PropertyCallAdapterProvider <T> .GetInstance(column.PropertyName).InvokeGet(item));
                    dr[name] = value;
                }
                dt.Rows.Add(dr);
            }

            return(dt);
        }
コード例 #5
0
 public void Add <V>(string key, V value)
 {
     ReflectionInoCore <V> .GetInstance().Add(key, value);
 }
コード例 #6
0
 public void Remove <V>(string key)
 {
     ReflectionInoCore <V> .GetInstance().Remove(key);
 }
コード例 #7
0
 public V GetOrCreate <V>(string cacheKey, Func <V> create, int cacheDurationInSeconds = int.MaxValue)
 {
     return(ReflectionInoCore <V> .GetInstance().GetOrCreate(cacheKey, create));
 }
コード例 #8
0
 public IEnumerable <string> GetAllKey <V>()
 {
     return(ReflectionInoCore <V> .GetInstance().GetAllKey());
 }
コード例 #9
0
 public V Get <V>(string key)
 {
     return(ReflectionInoCore <V> .GetInstance().Get(key));
 }
コード例 #10
0
 public bool ContainsKey <V>(string key)
 {
     return(ReflectionInoCore <V> .GetInstance().ContainsKey(key));
 }
コード例 #11
0
 public void Add <V>(string key, V value, int cacheDurationInSeconds)
 {
     ReflectionInoCore <V> .GetInstance().Add(key, value, cacheDurationInSeconds);
 }
コード例 #12
0
ファイル: ContextMethods.cs プロジェクト: tobaba/SqlSugar
 public void RemoveCacheAll <T>()
 {
     ReflectionInoCore <T> .GetInstance().RemoveAllCache();
 }