Home > Net >  EF USES AddRange batch adding data, how to convert format?
EF USES AddRange batch adding data, how to convert format?

Time:12-10

String [] array={" zhang ", "li si", "detective"};

Public partial class person
{
[Key]
While [StringLength (64)]
Public string name {get; set; }
}

In the database table "person" is only a string field, how do I turn the format of the string array, can make the final use AddRange () batch of new to this list "people"?

Gestalt fills up the words is this:
Database.. AddRange (___________________);
The database library. SaveChanges ();

CodePudding user response:


 
ListForeach (var s in array)
List. The Add (new person () {} name=s);

Database.. AddRange (list);
The database library. SaveChanges ();

CodePudding user response:

reference 1st floor icoolno1 response:
 
ListForeach (var s in array)
List. The Add (new person () {} name=s);

Database.. AddRange (list);
The database library. SaveChanges ();
this I can traverse, is cannot go directly?

CodePudding user response:

refer to the second floor Chinese naming advocates response:
Quote: refer to 1st floor icoolno1 response:

 
ListForeach (var s in array)
List. The Add (new person () {} name=s);

Database.. AddRange (list);
The database library. SaveChanges ();
this I can traverse, is cannot go directly?


String with the class and incompatible, zha, grammar does not support didn't also way,
  •  Tags:  
  • C#
  • Related