LINQ 用法集锦一

绑定下拉菜单方法:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

DepartmentsBusiness db = new DepartmentsBusiness();

IQueryable<COM_Departments> dp = db.GetDepartments("出版");

foreach(var a in dp)

{

ddlSearchDepartment.Items.Add(a.DepartmentName);

}

绑定DataList/DataGrid/GridView方法:

BargainDefineBusiness bdb = new BargainDefineBusiness();

var aa = bdb.GetBookInfoForView(str1);

//GetBookInfoForView()方法返回的是IQureable类型)

dlBookInfo.DataSource = aa;

dlBookInfo.DataBind();

删除数据的方法:

CCPressDataContext cp = new CCPressDataContext();

COM_BookInfoMaterial aa = cp.COM_BookInfoMaterial.Single(a => a.ID == id);

cp.COM_BookInfoMaterial.DeleteOnSubmit(aa);

cp.SubmitChanges();

在linq中,请问如何取得当前插入行的自增标识ID的值?

CCPressDataContext cp = new CCPressDataContext();

cp.PAY_BookExpensePerson.InsertOnSubmit(bookExpensePerson);

cp.SubmitChanges();

int a=bookExpensePerson.id;(即可取得自增长的id)。

你可能感兴趣的:(xml,Microsoft,Office,LINQ,出版)