yodeski / dapper-dot-net

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

convertion from string to byte[] #135

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

The output from SQL Query is in string(base64 converted) format.The objective 
is to convert the string to byte[]. How can I achieve this ?

Original issue reported on code.google.com by nprasad....@gmail.com on 2 May 2013 at 3:43

GoogleCodeExporter commented 9 years ago
Dapper is intended to be a bridge to your storage; if you stored the data as a 
string, dapper will help you retrieve it as a string - so I suggest simply 
*treat it as a string* at the POCO layer. Then *completely separate to dapper*, 
just base-64 decode it as some point.

If you really really want to do it in one go, you could use properties to do it 
on-the-fly, for example:

    public string Value {get;set;}
    public byte[] ValueBytes {
        get { return Value == null ? null : Convert.FromBase64String(Value); }
        set { Value = value == null ? null : Convert.ToBase64String(value); }
    }

Original comment by marc.gravell on 2 May 2013 at 11:43