netpyoung / SqlCipher4Unity3D

💾 SqlCipher made easy for Unity3d
MIT License
165 stars 37 forks source link

[Ignore] attribute doesn't work #23

Closed Salbrox closed 5 years ago

Salbrox commented 5 years ago

I have a property that I do not wish to be created in my db. I put the [Ignore] attribute before the property but it doesn't seem to work:

public string ID { get; set; }
public string CompanyID { get; set; }
[Ignore]
public Company Company
{
    get
    {
        return DataService.SelectRecord<Company>("ID", CompanyID);
    }
    set
    {
        CompanyID = value.ID;
    }
}
public string UserName { get; set; }
public string FullName { get; set; }`

When I run I get:

NotSupportedException: Don't know about Company

netpyoung commented 5 years ago

Sorry I cannot fully understand your current situation.

I added test code then the test was passed

Could you review that?

Salbrox commented 5 years ago

I tried the test and it passes. But the issue still persists in my code. The [Ignore] attribute still does not work. I cannot see what I might be doing wrong.

netpyoung commented 5 years ago

Could you check this attribute is correct?

using IgnoreAttribute = SQLite.Attribute.IgnoreAttribute;

I suspicious that line

        return DataService.SelectRecord<Company>("ID", CompanyID);

Could you try make empty table then check the result of that?

            Conn.CreateTable<Company>();
Salbrox commented 5 years ago

I was using the wrong lib. I removed it and added:

using IgnoreAttribute = SQLite.Attribute.IgnoreAttribute; using PrimaryKeyAttribute = SQLite.Attribute.PrimaryKeyAttribute;

Its working fine now. Thanks for your help.