User Agreements in Entity Framework 6

I want to create a convention where EF can serialize IEnumerable<String>

to a format (comma separated values ​​for example) and store them in a column, and when retrieved, create them again IEnumerable<String>

.

The msdn link http://msdn.microsoft.com/en-us/data/jj819164.aspx mentions the following example

class DateTimeColumnTypeConvention : IConfigurationConvention<PropertyInfo, DateTimePropertyConfiguration>
{
    public void Apply(
        PropertyInfo propertyInfo, Func<DateTimePropertyConfiguration> configuration)
    {
        // If ColumnType hasn't been configured...
        if (configuration().ColumnType == null)
        {
            configuration().ColumnType = "datetime2";
        }
    }
}

      

But I need something like

class DateTimeColumnTypeConvention : IConfigurationConvention<PropertyInfo, IEnumerable<string>>
   {
       public void Apply(PropertyInfo propertyInfo, Func<IEnumerable<string>> configuration)
        {
           // Get all the values of the property here, create a comma separated string ,ask EF to store this string by setting the ColumnType to varchar and then get it back.
        }
    }

      

I cannot find any obvious way to do this. Any ideas?

+3


source to share





All Articles