问题描述
嘿伙计们,我需要一些帮助,因为我不知道如何使用ILis
Hey guys, I need some help here, cause I don't know how to work with ILis
我正在尝试制作自己的博客和CMS,但我陷入了困境...
I'm trying to make my own blog and CMS, but i'm stuck in a point...
我与我的数据库(NHibernate,SQL Server)建立了连接,返回IList(下面的代码):
I Have a connection with my database (NHibernate, SQL Server), that return an IList (Code below):
public IList<Post> ReadPost(){
using (ISession session = FluentySessionFactory.AbriSession())
{
ISQLQuery query = session.CreateSQLQuery("select Id, Title, Author, Subtitle, Content from tbl_post");
query.AddEntity(typeof(Post));
return query.List<Post>();
}
}
在我的blog.aspx上我有一个标签,在页面加载时执行此操作(示例):
And on my blog.aspx I have a label, that on page load do this (Example):
lblPost.Text = "<div class='list'><h1>" + Post.ReturnById(1).Title+ "</h1><h5>"+ Post.ReturById(1).Subtitle+ "</h5></div>";
Post.ReturnById()工作正常,但我需要说出我想要的内容。所以我需要它来制作一个搜索我的数据库中的每个Id并写在lblPost上的foreach。所以它可以像博客一样。
Post.ReturnById() is working perfect, but I need to say what Id I want. So what I need it to make a foreach that searches every Id on my database and write on lblPost. So it can be like a blog.
嗯,我认为这就是我需要的,如果还有其他方法,我会很乐意听到,因为它不需要完全在IList,但是我现在拥有的。
Well, I think that's what I need, if there is another way to do so, I will love to hear about, cause it don't need exactly to be in IList, but that what I have now.
推荐答案
这篇关于的IList< T>和foreach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!