0

table:ProductComapny

field:NameProduct

NameProduct

1

1

1

4

5

i want update fields NameProduct where NameProduct= 1 to(NameProduct=1,NameProduct=2,NameProduct=3

how can this work??

result

NameProduct

1

2

3

4

5

1
  • Post what you have tried so far. Commented Aug 18, 2011 at 14:10

2 Answers 2

1
var source = new int[] {1,1,1,4,5};
var result = source.Select( (val,i) => val==1 ? i : val );
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.