fmwviormv / sqlite-net

Automatically exported from code.google.com/p/sqlite-net
0 stars 0 forks source link

Support column collation #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I added support for setting collation for columns, hard to submit a patch 
because of other modifications, but here are the pieces:

Add Class: 

public class CollationAttribute: Attribute
    {
        public string Value { get; private set; }
        public CollationAttribute( string collation )
        {
            Value = collation;
        }
    }

Add to Column class: 

public string Collation { get; protected set; }

Add to PropColumn constructor:

Collation = Orm.Collation( prop );

Add to ORM:

public static string Collation( PropertyInfo p )
        {
            var attrs = p.GetCustomAttributes( typeof( CollationAttribute ), true );
            if( attrs.Length > 0 )
                return ((CollationAttribute)attrs[0]).Value;
            else
                return string.Empty;
        }

Add to SqlDecl after IsNullable:

if( !string.IsNullOrEmpty( p.Collation ) )
                decl += "COLLATE " + p.Collation + " ";

Original issue reported on code.google.com by roman...@gmail.com on 23 Oct 2010 at 4:07

GoogleCodeExporter commented 9 years ago
Added code. Works great, thanks! R66

Original comment by frank.al...@gmail.com on 13 Nov 2010 at 11:28