开发者

DataBinding from Entity Framework to Listivew dataSource

开发者 https://www.devze.com 2023-04-13 00:54 出处:网络
My entity is returning the following: class StoreClass{ public Entry GetStoreInfo(int id, UserInfo userInfo)

My entity is returning the following:

class StoreClass{

    public Entry GetStoreInfo(int id, UserInfo userInfo)
    {
       using (var context = new StoreEntities())
       {
          var query = from a in context.Store
            .Include("Ratings")
            .Include("Versions")
            .Include("Versions.Installers")
            .Include("Versions.Installers.Screenshots")
            .Include("Category")
            where a.ID == id && a.IsActive 
         select a;
    return query.FirstOrDefault();
             }
    }
    }

I am trying to bind the data data returned form the above function to the listview.

StoreClass objStore = new StoreClass ();
            Listview1.DataSource = objStore .GetStoreInfo(1,userInfo);
            LstAppletInfo.DataBind();
        }

But its throwing an error "Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDa开发者_高级运维taSource."

Help me solve this!!!


public IEnumerable<Entry> GetStoreInfo(int id, UserInfo userInfo) 
{ 
    ...
    return query; 
} 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号