#
droren
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
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