sqlsugar两种in查询方式

int [] allIds =new int[]{2,3,31};
db.Queryable<OrderItem>().Where(it => allIds.Contains(it.OrderId)).ToList()
 List<IConditionalModel> conModels = new List<IConditionalModel>();
conModels.Add(new ConditionalModel { FieldName = "TradeNo", ConditionalType = ConditionalType.In, FieldValue = payRecordList.Join(r => r.TradeNo, ',') });
            var refundRecordList = Db.Queryable<Payment_RecordDetail>()
                .Where(conModels).Sum(i => i.Amount);

枚举字符串转换为对应的枚举对象(枚举code 转 枚举对象)

支持写法:

object?.ToEnum<SettleAccountType?>()?.GetStringValue(); //GetStringValue为获取枚举描述值 
        /// <summary>
        /// 枚举扩展方法提取字符串值
        /// Will get the string value for a given enums value, this will
        /// only work if you assign the StringValue attribute to
        /// the items in your enum.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetStringValue(this Enum value)
        {
            // Get the type
            Type type = value.GetType();

            // Get fieldinfo for this type
            FieldInfo fieldInfo = type.GetField(value.ToString());

            // Get the stringvalue attributes
            StringValueAttribute[] attribs = fieldInfo.GetCustomAttributes(
                typeof(StringValueAttribute), false) as StringValueAttribute[];

            // Return the first if there was a match.
            return attribs.Length > 0 ? attribs[0].StringValue : null;
        }

                /// <summary>
        /// 从枚举中获取Description
        /// 说明:
        /// 单元测试-->通过
        /// </summary>
        /// <param name="enumName">需要获取枚举描述的枚举</param>
        /// <returns>描述内容</returns>
        public static string GetDescription(this Enum enumName)
        {
            try
            {
                string _description = string.Empty;
                FieldInfo _fieldInfo = enumName.GetType().GetField(enumName.ToString());
                DescriptionAttribute[] _attributes = _fieldInfo.GetDescriptAttr();
                if (_attributes != null && _attributes.Length > 0)
                    _description = _attributes[0].Description;
                else
                    _description = null;//enumName.ToString();
                return _description;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        /// <summary>
        /// 枚举字符串转换为对应的枚举对象(枚举code 转 枚举对象)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="code">枚举Code</param>
        /// <returns></returns>
        public static T ToEnum<T>(this string code)
        {
            Type type = typeof(T);
            var enumType = type.IsEnum ? type : Nullable.GetUnderlyingType(typeof(T));
            var isDefined = false;
            if (int.TryParse(code, out int n))
            {
                isDefined = System.Enum.IsDefined(enumType, n);
            }
            else
            {
                isDefined = System.Enum.IsDefined(enumType, code);
            }

            if (isDefined && System.Enum.TryParse(enumType, code, true, out object enumObj))
            {
                return (T)enumObj;
            };
            return default(T); //default(T)会根据T返回 ,如T为可空时可能返回null,T为具体enum时一定不会返回null
        }

mysql测试行锁

https://blog.csdn.net/qq_21891743/article/details/85096819?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-4&spm=1001.2101.3001.4242

start TRANSACTION
select *From test where id=11 for update;
-- commit 
start TRANSACTION
update test set id=111 where id =11;
-- commit 
show OPEN TABLES where In_use > 0;