table:ProductComapny
field:NameProduct
NameProduct
1
1
1
4
5
i want update fields NameProduct where NameProduct= 1
to(NameProduct=1
,NameProduct=2
,NameProdu开发者_JAVA百科ct=3
how can this work??
result
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 );
Try This:
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++;
}
}
精彩评论