开发者

Problem updating multi-row

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++;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜