0

I am hoping to provide just enough information so as not to bore anyone.

I have a model that creates a user, which has various properties including an array of specializations:

public class User
{
    ...
    public string[] specializations { get; set; }
}

Part of my query retrieves the specializations as a delimited list:

STUFF(( SELECT  ';' + csc.description
        FROM    certified_specialization_code csc
            INNER JOIN  certified_specialization cs ON  csc.specialization_code = cs.specialization_code
        WHERE   cs.member_number = m.entity_number)
        FOR XML PATH('')), 1, 1, '' ) AS specializations,

I then take the query values and assign them to my model:

while (reader.Read())
{
    ...
    member.specializations = reader["specializations"];
    ...
}

What is the proper syntax to take that string and assign it to member.specializations, the string[]?

Connie DeCinko
  • 996
  • 5
  • 19
  • 39

1 Answers1

0

Just like you'd split any other string:

member.specializations = reader["specializations"].ToString()
                                                  .Split(';');
D Stanley
  • 149,601
  • 11
  • 178
  • 240