This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / query hierarchical data to an unordered list in HTML...should be a challenging qry for the afternoon. prefer T-SQL. 暂时不考虑LINQ. thanks.
-sunday8(每个年头都有新的梦景);
2009-8-13
{608}
(#5482053@0)
-
more three hours by T-SQL VS 10 minutes by LINQ
-deep_blue(BLUE);
2009-8-15
{3148}
(#5486152@0)
-
You have given me hope.. thanks.
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488739@0)
-
Mixing SQL with HTML codes would be a bad practice. If I do, I would query database, wrap dataset with XML, let it become a general http/xml output, then write stylesheet to transform xml to html or pdf format for whatever UI you prefer.
-nicetomeetyou(蓦然回首彩虹跨天地);
2009-8-17
(#5488828@0)
-
I prefer to LINQ rather any thing else.
-deep_blue(BLUE);
2009-8-17
(#5488844@0)
-
yes. LINQ looks promising. will integrate linq into the project on next version.
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488906@0)
-
关键是你用了递归,和你抬一下杠:把数据简单放到DataTable,简单做个递归,不用LINQ,10分钟也能完成。
-tjhong(我检讨);
2009-8-17
(#5488913@0)
-
嗯,此题关键是用递归,用LINQ是简化里面具体的实现步骤
-binghongcha76(一只大猫);
2009-8-17
(#5488973@0)
-
Read my code carefully. Recursion is important. Inside recursive method, it’s not necessary to use LINQ query. However, group join and ToLookup() method are all put thing very simple.
-deep_blue(BLUE);
2009-8-17
(#5489223@0)
-
Exactly. it’s not necessary to use LINQ query.I can use DataTable.Select Method intead of Enumerable.ToLookup Method. Sometimes using a loop is not a big deal. using DataColumn.Expression Property is easy to create a parent's parent column instead of join.
-tjhong(我检讨);
2009-8-17
{212}
(#5489303@0)
-
就是说LINQ会有些优点,这3小时和10分钟的差异不能把帐全记在LINQ上。
-tjhong(我检讨);
2009-8-17
(#5489327@0)
-
First of all, I compared T-SQL with LINQ. Secondly, I suggest that you write out a non-LINQ code to see how long can you spend.
-deep_blue(BLUE);
2009-8-17
(#5489481@0)
-
I am good at VB.NET, So I use VB.NET. less than 20 minutes without LINQ.
-tjhong(我检讨);
2009-8-17
{2057}
(#5489600@0)
-
有个笔误,更正版
-tjhong(我检讨);
2009-8-17
{1984}
(#5489618@0)
-
Did you test your code? I guess not. At beginning it losses root element already.
-deep_blue(BLUE);
2009-8-18
(#5490966@0)
-
这么说就没劲了,现在给你一段测试过的代码,您老点评点评LINQ高明在哪?我看只有简单问题复杂化。
-tjhong(我检讨);
2009-8-18
{3379}
(#5491039@0)
-
Every one has his (her) own style.Most tasks can be done by different approaches, even very old ones. Following some things called best practice can make codes well-structured and easy to read and maintenance.
-deep_blue(BLUE);
2009-8-18
{176}
(#5491089@0)
-
Come on, lookup is totally differnt from select. Check out LINQ's loopup menthod.
-deep_blue(BLUE);
2009-8-17
(#5489465@0)
-
这个的论坛里你应该是比较用功的一位,就是缺少灵活性,DataTable.Select Method 返回值一个是数组,Lookup返回值一个是字典,数组用
for (int i = 1; i <= 5; i++)
{
}
字典用 for each循环
这个地方咋就非得用字典不能用数组?
-tjhong(我检讨);
2009-8-17
{121}
(#5489531@0)
-
No. lookup returns groups. In tree strccture, it needs only one parent for each group, rather than every item's parent data.
-deep_blue(BLUE);
2009-8-17
(#5489562@0)
-
这个,ToLookUp返回的不是一个简单的字典,ToDictionary才是一个字典。ToLookUp返回的是一个IEnumerable的key, value值,和字典很像,但是其Value是一个经过GroupBy的IEnumerable值。和DataTable的Select返回值性质不太一样
-binghongcha76(一只大猫);
2009-8-17
(#5489580@0)
-
It's just used by For Each. We don't use other features of lookup.
-tjhong(我检讨);
2009-8-17
(#5489606@0)
-
哈哈,看你们两位一直推销LINQ,我拉开门往里偷窥一把,所以我就2天的LINQ经验,LINQ可能会有FANCY的地方。但你们两还没拿出太吸引人的地方,.NET太浩瀚,这好象非LINQ不可的地方不多。
-tjhong(我检讨);
2009-8-17
(#5489888@0)
-
哥们误会了,这道题我上边回帖很清楚了,重点是这个递归算法,LINQ只是使得算法实施起来更容易一些,说白了,这题其实和LINQ没多大关系
-binghongcha76(一只大猫);
2009-8-17
{557}
(#5490402@0)
-
呵呵,不用扣字眼嘛,说推销也无妨,毕竟这个LINQ你们有经验,不过说实话,玩WCF,Ajax等比玩LINQ有劲,LINQ只不过是一个nice to have的东西。
-tjhong(我检讨);
2009-8-17
(#5490506@0)
-
想过用xsl,不过对这不是很熟,会耗时日。下个version吧。
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488891@0)
-
Data, Control, and View are three different entities. Separating them in software design is required in any serious project.
-nicetomeetyou(蓦然回首彩虹跨天地);
2009-8-17
(#5488907@0)
-
You are absolutely Right! 只是有时杀鸡不用牛刀。:)
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488922@0)
-
I understand.:-) I just hate to integrate html into sql code. One concern would be: What if returned string contains "<", etc special characters? It breaks your work...
-nicetomeetyou(蓦然回首彩虹跨天地);
2009-8-17
(#5488944@0)
-
写一段procedure用cursor就成了,不是很麻烦。
-canadiantire(轮胎 - Cornelius);
2009-8-17
(#5488794@0)
-
no cursor pls. :)
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488877@0)
-
Oracle用不着, 但是T-SQL, 我是4,5年以前做过这个,当时也没什么好办法,只能用cursor.tree本身就是比较慢的结构,无论是用SQL还是显示到HTML上面, 如果数比较大,cursor在这里不会是瓶颈,HTML和JS的速度将会是瓶颈。。。
-canadiantire(轮胎 - Cornelius);
2009-8-17
(#5488890@0)
-
oracle "connect by" ?
-win(秋天的菠菜);
2009-8-17
(#5488801@0)
-
确是从一段oracle "connect by" qry来的灵感。
-sunday8(每个年头都有新的梦景);
2009-8-17
(#5488898@0)