public void selectqueryasso()
{
CustomerOrderResult cso=new CustomerOrderResult();
var a = (from as1 in ds.orders
from as2 in ds.order_details
where (as1.oid == as2.oid)
orderby as1.pname
select new CustomerOrderResult
{
oid = Convert.ToInt32(as1.oid),
cmny =as1.cmny,
ocountry=as1.ocountry,
pname=as1.pname,
price= Convert.ToString(as1.price),
orderno= Convert.ToString(as1.orderno),
saltitle=as1.saltitle
}).ToList<CustomerOrderResult>;
GridView1.DataSource = a;
GridView1.DataBind();
}
无法将方法组分配给隐式类型的局部变量 无法将方法组分配给隐式类型的局部变量 无法将方法组分配给隐式类型的局部变量
答案 0 :(得分:2)
你实际上并没有调用ToList()
方法,你错过了那里的括号:
public void selectqueryasso()
{
CustomerOrderResult cso=new CustomerOrderResult();
var a = (from as1 in ds.orders
from as2 in ds.order_details
where (as1.oid == as2.oid)
orderby as1.pname
select new CustomerOrderResult
{
oid = Convert.ToInt32(as1.oid),
cmny =as1.cmny,
ocountry=as1.ocountry,
pname=as1.pname,
price= Convert.ToString(as1.price),
orderno= Convert.ToString(as1.orderno),
saltitle=as1.saltitle
}).ToList<CustomerOrderResult>();
GridView1.DataSource = a;
GridView1.DataBind();
}