Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# droren 3/18/2007 1:51 PM
I want to display the top 5 articles from article module in specific section
so in order to do this I create new project NewsRepeater and declare 2 file
newsrepeatermodule.cs , newsrepeater.ascx
the newsRepeater.ascx looks like this
public partial class NewsRepeater : BaseModuleControl
{
private NewsRepeaterModule _module;
private IList _newsList;
private int sectionid;
protected void Page_Load(object sender, EventArgs e)
{
this._module = this.Module as NewsRepeaterModule;
if (!this.IsPostBack)
{
if (int.TryParse(Config.GetConfiguration()["ParentSectionId"], out sectionid))
BindNews();
}
}

private void BindNews()
{
_newsList = _module.GetArticleListBySectionId(sectionid);
rptNews.DataSource = _newsList;
Response.Write(_newsList.Count);
rptNews.DataBind();
}
}

the NewRepeaterModule looks like this: I declare 2 methos , it's only different syntax, both of them return the same error

public IList GetArticleListBySectionId(int sectionId)
{
string hql =
"from Article where a.SectionId = :sectionId ";
IQuery q = this._sessionManager.OpenSession().CreateQuery(hql);
q.SetInt32("sectionId", sectionId);
return q.List();
}

public IList GetArticleListBySectionId1(int sectionId)
{
ISession session = _sessionManager.OpenSession();
return session.CreateCriteria(typeof (Article)).List();

}

it important to mention that the article module is not in the same project
I'm getting the error that article isn't mapped
what's the problem??

thanx
# martijnb 3/18/2007 3:23 PM
The problem with this approach is the lazy-loading behavior of the module loader. When your module is loaded first, the Articles module might not be loaded (and thus, the mapped classes are not known).

Maybe a workaround is possible, by also embedding the mapping files of the articles module in your module. Just an idea from the top of my head. No idea if it works.
# droren 3/25/2007 7:19 AM
for a future use:
to resolve the problem you must include the article,category,comment hbl files in order to get it work!