I'm working with a legacy database that stores a boolean column as a string, where true is "Y" and false is an empty string. How would I map a property so that it's able to convert this value to an actual boolean, but still save to the database as "Y" and empty 开发者_运维知识库string, for legacy purposes?
I would take care of this with custom getters and setters. Just create your own getProperty
and setProperty
methods that will convert the value both directions. I don't know that there's any other way to programatically change the meaning of a value directly through the property mappings.
function setProperty(value){
if(Arguments.Value){
this.Property = "Y";
}else{
this.Property = "";
}
}
function getProeprty(){
return (this.Property EQ "Y");
}
精彩评论