I declare following class in c#
[Table("Employee")]
public class Employee
{
[PrimaryKey,AutoIncrement]
public int EmployeeId { get; set; }
public DateTime DateOfJoining { get; set; }
public string Address{ get; set; }
}
and i invoke this method to create equivalent table in my SQLite database
public async Task CreateTable()
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
await conn.CreateTableAsync<Employee>();
}
So it creates a table in SQLite as follows
[EmployeeId] int,
[DateOfJoining] [datetime],
[CallType] [varchar]
I wanted To create a a column, which is bit
[IsActive] [bit]
For this I tried
public bool IsActive { get; set; }
and
public Boolean IsActive { get; set; }
Both these properties result in a column which is an integer
[IsActive] integer
So how should I declare my IsActive property to get a column with bit as datatype.
I have one more question, If i declare property and specify it as not null
[NotNull]
public bool Address{ get; set; }
Then it gives me an error when I invoke CreateTable() saying, "No default value specified for Not Null attribute".
I tried to initialise this property in constructor, but it didnt work.
How do I go about these issues? Please Help
Aucun commentaire:
Enregistrer un commentaire