55\=============================================================================================================================*/
66using System ;
77using System . Collections . Generic ;
8+ using System . Data ;
9+ using System . Data . SqlClient ;
10+ using System . Diagnostics ;
11+ using System . Diagnostics . Contracts ;
12+ using System . Globalization ;
813using System . Linq ;
914using System . Text ;
10- using System . Threading . Tasks ;
11- using Ignia . Topics . Repositories ;
12- using System . Diagnostics . Contracts ;
13- using System . Data . SqlClient ;
14- using System . Data ;
15- using System . Xml ;
1615using System . Web ;
17- using System . Globalization ;
16+ using System . Xml ;
1817using Ignia . Topics . Collections ;
19- using System . Diagnostics ;
2018using Ignia . Topics . Querying ;
19+ using Ignia . Topics . Repositories ;
2120
2221namespace Ignia . Topics . Data . Sql {
2322
@@ -67,7 +66,7 @@ public SqlTopicRepository(string connectionString) : base() {
6766 /*==========================================================================================================================
6867 | METHOD: ADD TOPIC
6968 \-------------------------------------------------------------------------------------------------------------------------*/
70- private static void AddTopic ( SqlDataReader reader , Dictionary < int , Topic > topics , out int sortOrder ) {
69+ private static void AddTopic ( SqlDataReader reader , Dictionary < int , Topic > topics ) {
7170
7271 /*------------------------------------------------------------------------------------------------------------------------
7372 | Identify attributes
@@ -77,8 +76,6 @@ private static void AddTopic(SqlDataReader reader, Dictionary<int, Topic> topics
7776 var contentType = reader ? [ "ContentType" ] ? . ToString ( ) ;
7877 var key = reader ? [ "TopicKey" ] ? . ToString ( ) ;
7978
80- sortOrder = Int32 . Parse ( reader ? [ "SortOrder" ] ? . ToString ( ) , CultureInfo . InvariantCulture ) ;
81-
8279 // Handle ParentID (could be null for root topic)
8380 Int32 . TryParse ( reader ? [ "ParentID" ] ? . ToString ( ) , out parentId ) ;
8481
@@ -88,13 +85,6 @@ private static void AddTopic(SqlDataReader reader, Dictionary<int, Topic> topics
8885 var current = TopicFactory . Create ( key , contentType , id ) ;
8986 topics . Add ( current . Id , current ) ;
9087
91- /*------------------------------------------------------------------------------------------------------------------------
92- | Assign sort order, based on database order
93- \-----------------------------------------------------------------------------------------------------------------------*/
94- if ( current . SortOrder < 0 ) {
95- current . SortOrder = sortOrder ++ ;
96- }
97-
9888 /*------------------------------------------------------------------------------------------------------------------------
9989 | Assign parent
10090 \-----------------------------------------------------------------------------------------------------------------------*/
@@ -467,7 +457,6 @@ public override Topic Load(int topicId, bool isRecursive = true) {
467457 var topics = new Dictionary < int , Topic > ( ) ;
468458 var connection = new SqlConnection ( _connectionString ) ;
469459 var command = new SqlCommand ( "topics_GetTopics" , connection ) ;
470- var sortOrder = 0 ;
471460
472461 command . CommandType = CommandType . StoredProcedure ;
473462 command . CommandTimeout = 120 ;
@@ -497,7 +486,7 @@ public override Topic Load(int topicId, bool isRecursive = true) {
497486 \---------------------------------------------------------------------------------------------------------------------*/
498487 Debug . WriteLine ( "SqlTopicRepository.Load(): AddTopic() [" + DateTime . Now + "]" ) ;
499488 while ( reader . Read ( ) ) {
500- AddTopic ( reader , topics , out sortOrder ) ;
489+ AddTopic ( reader , topics ) ;
501490 }
502491
503492 /*----------------------------------------------------------------------------------------------------------------------
@@ -579,7 +568,7 @@ public override Topic Load(int topicId, bool isRecursive = true) {
579568 /*------------------------------------------------------------------------------------------------------------------------
580569 | Return objects
581570 \-----------------------------------------------------------------------------------------------------------------------*/
582- if ( topics . Count == 0 ) return new Topic ( ) ;
571+ if ( topics . Count == 0 ) return null ;
583572 return topics [ topics . Keys . ElementAt ( 0 ) ] ;
584573
585574 }
@@ -607,7 +596,6 @@ public override Topic Load(int topicId, DateTime version) {
607596 var topics = new Dictionary < int , Topic > ( ) ;
608597 var connection = new SqlConnection ( _connectionString ) ;
609598 var command = new SqlCommand ( "topics_GetVersion" , connection ) ;
610- var sortOrder = 0 ;
611599
612600 command . CommandType = CommandType . StoredProcedure ;
613601 command . CommandTimeout = 120 ;
@@ -637,7 +625,7 @@ public override Topic Load(int topicId, DateTime version) {
637625 | Populate topics
638626 \---------------------------------------------------------------------------------------------------------------------*/
639627 while ( reader . Read ( ) ) {
640- AddTopic ( reader , topics , out sortOrder ) ;
628+ AddTopic ( reader , topics ) ;
641629 }
642630
643631 /*----------------------------------------------------------------------------------------------------------------------
0 commit comments