Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Conversion capabilities between .NET and DB values #50

Open
flq opened this Issue May 18, 2011 · 6 comments

Comments

Projects
None yet
6 participants
Collaborator

flq commented May 18, 2011

Introduce converter functions which you can attach to columns. Syntax-wise it could look something like this:

var converterPlugin = new ConverterPlugin();
converterPlugin.Add(_db.Customers.Id, g => g.ToByteArray(), v => new Guid((byte[])v));
converterPlugin.Add(col=>col.Name.EndsWith("BOOL"), BoolToDb, DbToBool);

DatabaseOpener.Profiles.Add(cfg=> {
  cfg.Name = "ORCL";
  cfg.Connectionstring("...");
  cfg.AddPlugin(converterPlugin);
});

_db = Database.OpenProfile().ORCL;

Converters are applied when searching/updating inserting in that a provided .NET value passes through a converter, or when reading back values in that the DB value is converted to some .NET type.

It should have support for a single column definition, or a definition that defines a predicate that checks whether a given column should get the converters applied. That way one can do conversions for e.g. a specific column data type or based on some column naming convention.

This feature is based on the ideas put down in #56

@ghost ghost assigned flq May 19, 2011

This is definitely something I'd be interested in. I have char columns in a database that need to be surfaced as byte and byte[] in the objects. I haven't tried it with the database yet, but using the XmlMockAdapter I get conversion errors (cannot convert string to System.Byte[]).

Collaborator

richardhopton commented Nov 27, 2011

I've got a legacy database that stores booleans as CHAR(1) with Y or N - having a feature like this would be helpful.

Owner

markrendle commented Mar 30, 2012

This keeps coming up, so I'm going to pull it into v1.0, for a 0.17 pre-release. Spiking ideas at the moment.

@ghost ghost assigned markrendle and markrendle Mar 30, 2012

hmobius commented Jun 13, 2012

A quick ping on this issue - is it still on for v1.0? The roadmap I found suggests you've targeted it for v1.1

Owner

markrendle commented Jun 13, 2012

I was planning on putting it into 1.1 so that the gap between the
software and the docs didn't keep growing on you. I'll probably start
releasing 1.1.x-beta soon when I get to that stuff.

Sent from my iPad

On 13 Jun 2012, at 12:26, Dan Maharry
reply@reply.github.com
wrote:

A quick ping on this issue - is it still on for v1.0? The roadmap I found suggests you've targeted it for v1.1


Reply to this email directly or view it on GitHub:
#50 (comment)

I vote for that feature, too! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment