question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ColumnAttribute.Storage property does not work as expected

See original GitHub issue
    public class EncryptedString
    {
        private string _str= "Encrypted";
        [Column(Storage = "_str")]
        public string Str { get { return "Decrypted"; } set { _str = "Encrypted"; } }
    }

The idea here is to save encrypted string to DB and decrypt it when using inside the code. Bit it does not work

db.Insert(new EncryptedString());

inserts “Decrypted”, so storage is not used.

Also, when I query

db.Strings.Where(g => g.Str == "Decrypted")

It queries on “Decrypted” string, not “Encrypted”

Is it a bug? If not, how do I make it work?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ilicommented, Apr 7, 2017

What about:

public class EncryptedString
{
    public string Encrypted;
    public string Value { get {return Decrypt(Encrypted); } set {Encrypted = Encrypt(value); } }
}

public MyEntity 
{
    public EncryptedString Value {get;set;}
}

MappigSchema.SetConvertExpression<EncryptedString, DataParameter>(s => return new DataParameter() { Value = s.Encrypted });
MappigSchema.SetConvertExpression<string, EncryptedString>(s => return new EncryptedString() { Value = s});

this should work

Speaking about your suggestion, i think yes we should implement also read usage for storage.

1reaction
sdanylivcommented, Jun 14, 2020

Working on value converters, similar to HasConversion in EF Core. I hope will finish today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linq data mapping: usage of Storage property on column ...
With "a" I would expect this to fail, as it doesn't really know about the property ParentId (only the field m_parentid and the...
Read more >
Attribute-Based Mapping - ADO.NET
AssociationAttribute and ColumnAttribute Storage property values are case sensitive. For example, ensure that values used in the attribute ...
Read more >
Reference: Storage (Magic xpa 4.x)
If set to No, the column will be mapped according to the column's Storage property. The Default Storage property is also available for...
Read more >
Optimize NULL values storage consumption using SQL ...
SQL Server 2008 introduces a new column attribute that is used to reduce the storage consumed by NULL values in the database tables....
Read more >
Data Bound Columns - Telerik UI for Blazor
The grid skips fields marked with the IgnoreDataMemberAttribute when performing CUD operations. Its presence indicates that this property does not need to be ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found