internal static IEnumerable <PropertyFieldMapping> GetDbMapping(Type entityType)
 {
     return(from s in PropertyUnity.GetLoadedProperties(entityType, true)
            let name = string.IsNullOrEmpty(s.Info.FieldName) ? s.Name : s.Info.FieldName
                       let dbType = s.Info.DataType == null ? DbType.String : s.Info.DataType.Value
                                    select new PropertyFieldMapping(s.Name, s.Info.FieldName, s.Type, dbType)
     {
         ValueFunc = e => PropertyValueHelper.GetValueSafely(((IEntity)e).InternalGetValue(s))
     });
 }
 internal static IEnumerable <PropertyFieldMapping> GetDbMapping(Type entityType)
 {
     return(from s in PropertyUnity.GetLoadedProperties(entityType)
            where (!s.Info.IsPrimaryKey || (s.Info.IsPrimaryKey && s.Info.GenerateType != IdentityGenerateType.AutoIncrement))
            let name = string.IsNullOrEmpty(s.Info.FieldName) ? s.Name : s.Info.FieldName
                       let dbType = s.Info.DataType == null ? DbType.String : s.Info.DataType.Value
                                    select new PropertyFieldMapping(s.Name, s.Info.FieldName, s.Type, dbType)
     {
         ValueFunc = e => PropertyValue.GetValueSafely(((IEntity)e).GetValue(s))
     });
 }
 /// <summary>
 /// 获取可以读取值的属性名称序列。
 /// </summary>
 /// <returns>所有可以读取值的属性名称序列。</returns>
 public override IEnumerable <string> GetCanReadProperties()
 {
     return(from s in PropertyUnity.GetLoadedProperties(typeof(TEntity), true)
            select s.Name);
 }
 /// <summary>
 /// 读取实体实例的所有值。
 /// </summary>
 /// <param name="instance">要读取的实体实例。</param>
 /// <returns>所有属性的值。</returns>
 public override IEnumerable <object> ReadValues(TEntity instance)
 {
     return(PropertyUnity.GetLoadedProperties(typeof(TEntity), true)
            .Select(p => instance.InternalGetValue(p))
            .Select(value => PropertyValue.IsNullOrEmpty(value) ? null : value.GetStorageValue()));
 }