Exemplo n.º 1
0
        public static IEnumerable <Tuhu.Provisioning.DataAccess.Entity.Category> SelectProductCategoryCategoryNameAndDisplayName()
        {
            var dt = DALPromotion.SelectProductCategoryCategoryNameAndDisplayName();

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new Tuhu.Provisioning.DataAccess.Entity.Category[0]);
            }

            var result = dt.Rows.Cast <DataRow>().Select(row => new Tuhu.Provisioning.DataAccess.Entity.Category
            {
                CategoryName     = Convert.ToString(row["CategoryName"]),
                DisplayName      = Convert.ToString(row["DisplayName"]),
                oid              = Convert.ToInt32(row["oid"]),
                ParaentOid       = Convert.ToInt32(row["ParaentOid"]),
                ChildrenCategory = new List <Tuhu.Provisioning.DataAccess.Entity.Category>()
            }).ToArray();

            foreach (var category in result)
            {
                category.ParentCategory   = result.Where(c => category.ParaentOid == c.oid);
                category.ChildrenCategory = result.Where(c => c.ParaentOid == category.oid);
            }
            return(result);
        }