What is the best way to write a validation level for SQLite

I am using the ADO.net SQLite provider. I want to control some SQLite "functions", for example, allow a string in an integer field and allow a string longer than n in a field of type varchar (n). What is the best way to achieve this kind of validation? Stored procedures? triggers? I am looking for a universal solution that applies to any database, not just my database schema.

+3
source share
3 answers

You can add column constraints.

create table example
( 
  age integer not null check (typeof(age)='integer'),
  name text not null check (length(name) between 1 and 100),
  salary integer check (salary is null or typeof(salary)='integer')
)
+5
source

, , , . , ( mothersmaidenname - ). " " - ( ) , .

+1

Confirm in your C # the POCO domain model , and not in SQLite db, using something like DataAnnotationsor even this method .

0
source

Source: https://habr.com/ru/post/1723010/


All Articles