Domanda

Sto sviluppando un CMS che l'utilizzo di database basato su Joomla! In Joomla db, abbiamo 2 Tabella:

+----------+
|Categories|
+----------+
id
title
...

+-------+
|Content|
+-------+
id
title
catid
...

Ho una domanda qui sotto:

SqlQuery q = new Select("*")
                         //.Top("1")
                         .From(JosContent.Schema)
                         .InnerJoin(JosUser.IdColumn, JosContent.CreatedByColumn)
                         .InnerJoin(JosCategory.IdColumn, JosContent.CatidColumn)
                         .Where("catid").IsEqualTo(catId);

E nella pagina ASPX, mostro i dati del genere:

Tite : <%# DataBinder.Eval(Container.DataItem, "title") %>
In category : <%# DataBinder.Eval(Container.DataItem, "title") %> 
// Category tite not Content title, but ASP.NET think it is Content title :-(

Ti prego, aiutami a risolvere il problema? Come discean tra quella?

Grazie mille!

È stato utile?

Soluzione

È possibile fare riferimento alla tabella di title di Categories da: Categories.title e la title del tavolo Content da: Content.title. Scusate se ho frainteso la tua domanda.

Altri suggerimenti

Nel vostro prescelto si potrebbe fare come Alan ha detto, e quindi utilizzare AS per cambiare ciò che si fa riferimento a loro come in seguito. (Io non so specificamente ASP, io sono un programmatore PHP, ma suppongo che abbastanza similmente).

Qualcosa di simile

SELECT *, Categories.title AS categoryTitle, Content.title AS contentTitle ... ...

E poi si può fare riferimento a categoryTitle o contentTitle.

Ho finito:)

SqlQuery q = new Select("*", "jos_Categories.title AS 'CatTitle'")
                         //Select("*", "CatTitle = jos_Categories.title")
                         //Select("*", "CatTitle = JosCategory.TitleColumn")
                         //.Top("1")
                         .From(JosContent.Schema)
                         .InnerJoin(JosUser.IdColumn, JosContent.CreatedByColumn)
                         .InnerJoin(JosCategory.IdColumn, JosContent.CatidColumn)
                         .Where("catid").IsEqualTo(catId);

Grazie ... Google: -)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top