开发者

How can i add data programatically in linqqtosql?

i dislike below methods. Because more fields (suchas 开发者_开发百科150 fields) it is not good method. There is any SetValue method to add datato sql linqtosql for submitchanges?


 MyClass c = new MyClass ();
              c.FirstField = "bvnvb";
              c.......
              c...
              c...

             // Too many rows there is...
              engCtx.MyClass.InsertOnSubmit(c);
              engCtx.SubmitChanges();

How can i do with a loop method via using linq?

it is simple request why don't understand it is clear. i don't want to make it above is there any method like below?


foreach(...........)
engCtx.MyClass.Add(item);


It's not clear what you want.

The LINQ part of this is only two lines.

The "creating an object the way you want it part" is longer, but it's your object, it's under your control. Add a ctor which takes a number of parameters. Add SetXXXX() methods which set a number of properties at once. (Use partial classes if the main part of tha main is generated)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜