// 赋值属性 private static void SetProperty(object model, MemberAccessWrapper wrapper, object value) { try { Type memberType = wrapper.DataType; if ((memberType == typeof(bool) || memberType == typeof(bool?)) && (value.GetType() == typeof(short) || value.GetType() == typeof(int))) { value = value.GetType() == typeof(short) ? (short)value > 0 : (int)value > 0; } else if (memberType == typeof(Guid)) { byte[] b = value as byte[]; if (b != null) { value = new Guid(b); } } //else if (memberType != obj.GetType()) //{ // obj = Convert.ChangeType(obj, memberType); //} wrapper.Set(model, value); } catch (Exception ex) { throw new XfwException("invoke {0}={1} fail.", ex, wrapper.FullName, value); } }
// 初始化自增列信息 private void InitializeIdentity() { var rInfo = TypeRuntimeInfoCache.GetRuntimeInfo <T>(); _autoIncrement = rInfo.Wrappers.FirstOrDefault(x => { var column = (x.Value as MemberAccessWrapper).Column; return(column != null && column.IsIdentity); }).Value as MemberAccessWrapper; }