コード例 #1
0
        /// <summary>
        /// 把指定的实体列表中的数据完全转换到一个 DataTable 中。
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static DataTable ToDataTable(this EntityList list)
        {
            DataTable table = new DataTable();

            //找到属性容器
            var container  = list.GetRepository().EntityMeta.ManagedProperties;
            var properties = container.GetCompiledProperties();

            foreach (var property in properties)
            {
                //table.Columns.Add(property.Name, property.PropertyType);
                table.Columns.Add(property.Name, TypeHelper.IgnoreNullable(property.PropertyType));
            }

            list.EachNode(item =>
            {
                var row = table.NewRow();

                for (int j = 0, c2 = properties.Count; j < c2; j++)
                {
                    var property = properties[j];
                    var value    = item.GetProperty(property);
                    row[j]       = value ?? DBNull.Value;
                }

                table.Rows.Add(row);

                return(false);
            });

            return(table);
        }
コード例 #2
0
 /// <summary>
 /// 保存某个实体列表。
 /// </summary>
 /// <param name="entityList">The entity list.</param>
 public static void Save(EntityList entityList)
 {
     entityList.GetRepository().Save(entityList);
 }
コード例 #3
0
ファイル: AggtDeserializer.cs プロジェクト: 569550384/Rafy
 private static Entity FindOrCreate(EntityList list, JObject jEntity)
 {
     var id = TryGetId(jEntity);
     Entity child = null;
     if (id != null)
     {
         child = list.Find(id, true);
     }
     if (child == null)
     {
         child = list.GetRepository().New();
         list.Add(child);
     }
     return child;
 }