tags:

views:

19

answers:

2

When i call "f_CategoriNewsGet" function from Page_Load method I'm getting null. But i can see tblNewsler object is full with objects before return line.

protected void Page_Load(object sender, EventArgs e)
{
    var tblNewsler = News.f_CategoriNewsGet("ÇEVRE", 18); // return object is always
    Table<News> tblNewsler1 = tblNews;
    rptNatureNews.DataSource = tblNews != null ? tblNews.Take(6) : null;
    rptNatureNews.DataBind();
}

static public Table<News> f_CategoriNewsGet(string _sCategoriName, int _iTop)
{
    var tblNews = (from news in DAO.context.GetTable<News>()
                       join kategori in DAO.context.GetTable<NewsCategori>() on                                news.M_RefNewsCategoriId equals kategori.M_NewsCategoriId
                       where kategori.M_Adi.Equals(_sCategoriName)
                       orderby news.M_InsertDate descending
                       select news).Take(_iTop);
    return tblNews as Table<News>;
}
A: 

You got a bug here:

Table<News> tblNewsler1 = tblNews;

Should Be

Table<News> tblNewsler1 =  tblNewsler;
ozczecho
+1  A: 

tblNews is not a Table<News>. It is only an IQueryable<News>. context.GetTable<News> was a Table<News>, but applying query operators results in a different type -- the result of the query operator is no longer a Table<T>, but a (possibly internal) LINQ to SQL type representing the query.

itowlson