I have SQLite database in isolated storage in Windows Store App. I use SQLite for Windows Runtime
My class:
[Table("Projects")]
public class Project
{
[PrimaryKey]
[Column ("id")]
public int Id { get; set; }
[Column("group_id")]
public int GroupId { get; set; }
public string Name { get; set; }
}
I get data from web server and put it to local DataBase
. When I try to store data to DataBase
, I handled exeption
e.message = table Projects has no column named Name
because DataBase
haven't column "Name"
My question is: How to use one class with fields, maping to DataBase Column
and simple fields? (I wont not include some fields to DataBase
, but I need it in class.)
UPD.
using System.ComponentModel.DataAnnotations.Schema;
[NotMapped]
public string Name { get; set; }
Error The type or namespace name 'NotMappedAttribute' does not exist in the namespace 'System.ComponentModel.DataAnnotations.Schema' (are you missing an assembly reference?)
When I try to add System.ComponentModel.DataAnnotations.dll
Error: System.ComponentModel.DataAnnotations.dll could not be added. This component is already automaticaly referenced by the build system
System.ComponentModel.DataAnnotations.dll could not be added. This component is already automaticaly referenced by the build system
.
It seems you are using the sqlite-net library in this case you need to use the SQLite.IgnoreAttribute
[SQLite.Ignore]
public string Name { get; set; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.