[英]Problem updating multi-row
表格: ProductComapny
欄位: NameProduct
產品名稱
1個
1個
1個
4
5
我想要更新NameProduct = 1
到(NameProduct = 1
,NameProduct = 2
,NameProduct = 3
字段NameProduct
這怎么工作?
結果
產品名稱
1個
2
3
4
5
var source = new int[] {1,1,1,4,5};
var result = source.Select( (val,i) => val==1 ? i : val );
嘗試這個:
using (DataClassesDataContext dc=new DataClassesDataContext())
{
var my = from a in dc.ProductComapny
where a.NameProduct== 1
select a;
int i=1;
foreach (var item in my)
{
item.NameProduct= i;
dc.SubmitChanges();
i++;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.