Given a string of categories, I need to split the string and insert each separate item as a new record using EF.
The following does not work since string cannot be converted to Tag:
Dim s = "Books, Novels, Magazines"
s.Split(", ").ToList.ForEach(Function(x) _rdsqlconn.Tags.Add(x))
I have googled and not found an answer to my dilemma. How can i split the string and insert each as a new tag record?
I’m guessing that your Tag class has a property to which the string value is to be assigned.
This should work:
Edit: Had to look up the VB.NET object initializer syntax. Make sure you replace “Value” with whatever property your need to use and also make sure you leave the period in front of the property name.