Asp.net Can';我不能用C来计算IQueryable#
这是我的班级:Asp.net Can';我不能用C来计算IQueryable#,asp.net,.net,list,visual-studio-2012,iqueryable,Asp.net,.net,List,Visual Studio 2012,Iqueryable,这是我的班级: using System; using System.Collections.Generic; using System.Linq; using System.Web; { public class Attendee { public int AttendeeId { get; set; } public string FirstName { get; set; } public string LastName {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
{
public class Attendee
{
public int AttendeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
在代码的后面部分,我尝试使用该类,但它被声明为IEnumerable
:
IQueryable<Attendee> myList;
IQueryable myList;
我需要能够手动填充它。大概是这样的:
IQueryable<Attendee> districtList = new IQueryable<Attendee>() { AtendeeId = 1, FirstName = "First Name", LastName = "Last Name" }; <- This does not work. I need example of how to add one item or more then one item.
IQueryable districtList=new IQueryable(){AtendeeId=1,FirstName=“First Name”,LastName=“Last Name”} IQueryable
是一个接口,因此不能直接实例化它。相反,您需要创建实现接口的类的实例。例如:
List<string> myList = new List<string>(){"foo", "bar"};
IQueryable<string> myQueryable = myList.AsQueryable();
List myList=newlist(){“foo”,“bar”};
IQueryable myQueryable=myList.AsQueryable();
注意:在本例中,我使用LINQAsQueryable()
方法将IEnumerable
(即List
)转换为IQueryable
IQueryable
是一个接口,因此不能直接实例化它。相反,您需要创建实现接口的类的实例。例如:
List<string> myList = new List<string>(){"foo", "bar"};
IQueryable<string> myQueryable = myList.AsQueryable();
List myList=newlist(){“foo”,“bar”};
IQueryable myQueryable=myList.AsQueryable();
注意:在本例中,我使用LINQAsQueryable()
方法将IEnumerable
(即List
)转换为IQueryable
IQueryable
是一个接口,因此不能直接实例化它。相反,您需要创建实现接口的类的实例。例如:
List<string> myList = new List<string>(){"foo", "bar"};
IQueryable<string> myQueryable = myList.AsQueryable();
List myList=newlist(){“foo”,“bar”};
IQueryable myQueryable=myList.AsQueryable();
注意:在本例中,我使用LINQAsQueryable()
方法将IEnumerable
(即List
)转换为IQueryable
IQueryable
是一个接口,因此不能直接实例化它。相反,您需要创建实现接口的类的实例。例如:
List<string> myList = new List<string>(){"foo", "bar"};
IQueryable<string> myQueryable = myList.AsQueryable();
List myList=newlist(){“foo”,“bar”};
IQueryable myQueryable=myList.AsQueryable();
注意:在本例中,我使用LINQAsQueryable()
方法将IEnumerable
(即List
)转换为IQueryable
使用列表或数组(List
或Attendee[]
)来构建集合,然后调用AsQueryable()
,并将结果分配给变量。但是,这里使用IQueryable
确实不清楚您想要实现什么。myList
是什么?你是怎么定义的?请注意,IQueryable
实现IEnumerable
,而不是相反。使用列表或数组(list
或Attendee[]
)构建集合,然后调用AsQueryable()
并将结果分配给变量。但是,这里使用IQueryable
确实不清楚您想要实现什么。myList是什么?你是怎么定义的?请注意,IQueryable
实现IEnumerable
,而不是相反。使用列表或数组(list
或Attendee[]
)构建集合,然后调用AsQueryable()
并将结果分配给变量。但是,这里使用IQueryable
确实不清楚您想要实现什么。myList是什么?你是怎么定义的?请注意,IQueryable
实现IEnumerable
,而不是相反。使用列表或数组(list
或Attendee[]
)构建集合,然后调用AsQueryable()
并将结果分配给变量。但是,这里使用IQueryable
确实不清楚您想要实现什么。myList是什么?你是怎么定义的?请注意,IQueryable
实现了IEnumerable
,而不是相反。