postgresql - How to map a string property to a binary column in the database? -


i have class user entity. 1 of properties user's password (a hash, actually). made string (streamlined code):

public class user {     public virtual int id { get; set; }     public virtual string password { get; set; } } 

there's fluent nhibernate mapping (streamlined code):

public class usermap : classmap<user> {     public usermap()     {         table("users");         id(x => x.id).generatedby.sequence("users_id_seq");         map(x => x.password); // put here???     } } 

the database column of bytea data type on postgresql. above mapping doesn't work, because property string (text). should do?

you can make password public property, used reference underlying private property hashedpassword.
so:
protected virtual byte[] /*or whatever type is*/ hashedpassword {get; set;} public virtual string password
get
{
return (string)(hashedpassword); //or want cast string...
}
set
//...

you can tell fluent nhib ignore password property.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -