日期:2014-05-20 浏览次数:20960 次
public void GetData(IList<long> lst) {
MyConnection conn = new MyConnection (this.ConnectString);
MyDataContext db = new MyDataContext (conn);
var res=from al in db.MyTable
where lst.Contains(al.ID)
select al;
// do something
}
public void GetData(IList<long> lst) {
MyConnection conn = new MyConnection (this.ConnectString);
MyDataContext db = new MyDataContext (conn);
long[] ins =lst.ToArray();
var res=from al in db.MyTable
where ins.Contains(al.ID)
select al;
// do something
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace 图片翻页
{
public partial class WebForm1 : System.Web.UI.Page
{
public class mytable
{
public int ID { get; set; }
public string name { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<mytable> list = new List<mytable>() { new mytable() { ID = 10, name = "ID1" }, new mytable() { ID = 20, name = "ID2" }, new mytable() { ID = 40, name = "ID4" }, new mytable() { ID = 30, name = "ID3" } };
IList<long> lst = new List<long>() { 10, 20,40 };
var res = from al in list
where lst.Contains(al.ID)
select al;
res.ToList().ForEach(x => Response.Write(x.name));
}
}
}
}
[SerializableAttribute]
[ComVisibleAttribute(true)]
public abstract class Array : ICloneable,
IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable