Linq查询非泛型集合要指定Student类型(比如List)
2015-03-25 19:31
411 查看
#region Linq to 集合查询非泛型集合要指定Student类型
//ArrayList list = new ArrayList();
//list.Add(new Student { Name = "Tom", Age = 17 });
//list.Add(new Student { Name = "Jerry", Age = 16 });
//list.Add(new Student { Name = "Marry", Age = 18 });
//list.Add(new Student { Name = "Monika", Age = 22 });
//list.Add(new Student { Name = "Frank", Age = 20 });
//list.Add(new Student { Name = "Alex", Age = 15 });
////要指定Student类型
//var result = from Student s in list
// where s.Name.Contains("M") && s.Age >= 18
// select s;
//foreach (Student stu in result)
//{
// Console.WriteLine("学员姓名:{0},年龄:{1}", stu.Name, stu.Age.ToString());
//}
#endregion
//ArrayList list = new ArrayList();
//list.Add(new Student { Name = "Tom", Age = 17 });
//list.Add(new Student { Name = "Jerry", Age = 16 });
//list.Add(new Student { Name = "Marry", Age = 18 });
//list.Add(new Student { Name = "Monika", Age = 22 });
//list.Add(new Student { Name = "Frank", Age = 20 });
//list.Add(new Student { Name = "Alex", Age = 15 });
////要指定Student类型
//var result = from Student s in list
// where s.Name.Contains("M") && s.Age >= 18
// select s;
//foreach (Student stu in result)
//{
// Console.WriteLine("学员姓名:{0},年龄:{1}", stu.Name, stu.Age.ToString());
//}
#endregion
相关文章推荐
- linq查询结果转换为指定字段类型的list集合
- 指定查询条件,查询对应的集合List(单表)
- Linq To List 集合查询
- Linq集合查询出现无法将类型为“System.Int32”的对象强制转换为类型“System.String”异常
- 合并多个List<T>类型并通过LINQ按指定属性排序
- Linq之查询非泛型集合
- Linq EF 根据字符列表排序或List根据列表排序以及Linq查询类型转换
- C#.Net:List<T>集合列表的Linq语句查询示例
- List集合使用Linq进行in条件查询
- linq中查询列表的使用及iqueryable和list集合之间的转换
- OfType 使用LINQ查询动态数组中指定类型的元素
- 使用Enumerable.OfType<T>扩展方法实现非泛型集合的Linq查询
- Linq 学习(7) 延迟执行 & 查询非泛型集合
- EF调用存储过程查询表中的部分字段,报数据读取器与指定的“AdventureWorksDWModel.Student”不兼容。某个类型为“Age”的成员在同名的数据读取器中没有对应的列。
- Linq 学习(7) 延迟执行 & 查询非泛型集合
- 1.提取List<bean>中的某属性集合; 2.List<bean>排序(需要指定升序降序和排序字段的类型)
- Sharepoint学习笔记---SPList--使用Linq to Sharepoint间接查询External List(1.通过BCS创建External List)
- C# 泛型集合List和非泛型集合ArrayList的性能比较
- 光脚丫学LINQ(012):LINQ查询操作中的类型关系
- Oracle PLSQL Demo - 16.弱类型REF游标[没有指定查询类型,已指定返回类型]