Binding GridView to IQueryable

后端 未结 3 1339
有刺的猬
有刺的猬 2021-01-05 23:41

This question is purely academic, because I\'d never dream of doing this in real code.

Using LINQ to SQL, I want to bind an IQueryable

3条回答
  •  走了就别回头了
    2021-01-06 00:34

        public IQueryable MembershipGetAll()
        {
    
    
                var obj = (from mem in db.GetTable()
                               select new
                               {
                                   NAME = mem.MEMBERSHIP.NAME,
                                   TYPE = mem.MEMBERSHIP.TYPE,
                                   TAX_ID = mem.TAX_RATE.TAX_ID,
                                   DISCOUNT = mem.DISCOUNT,
                                   DISCOUNT_PERCENT = mem.DISCOUNT_PERCENT,
    
                               }
                              ).AsQueryable();
                return obj;
    
        }
    
    
    private void LoadMembership()
    {
        IQueryable mem = null;
        mem = eb.MembershipGetAll();
        grdMembership.DataSource = mem;
        grdMembershipRates.DataBind();
    }
    

    Just do it like this

提交回复
热议问题