Esempio n. 1
0
        private List <SqlParameter> GetUpdateParameter(object obj)
        {
            var cacheKeyName  = ((T)obj).GetTableName();
            var propertyInfos = MyCache.GetMyCachedItem(cacheKeyName);

            if (propertyInfos == null)
            {
                propertyInfos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                MyCache.AddToMyCache(cacheKeyName, propertyInfos, CacheItemPriority.Default);
            }

            var sqlParams = (from f in propertyInfos let cols = f.GetCustomAttributes(typeof(DbColumnAttribute), false)
                                                                where cols.Length > 0
                                                                let p = cols[0]
                                                                        select new SqlParameter(((DbColumnAttribute)p).Name, f.GetValue(obj, null))).ToList();

            return(sqlParams);
        }