Hi.Ltd.SQLite
2024.4.16.933
See the version list below for details.
dotnet add package Hi.Ltd.SQLite --version 2024.4.16.933
NuGet\Install-Package Hi.Ltd.SQLite -Version 2024.4.16.933
<PackageReference Include="Hi.Ltd.SQLite" Version="2024.4.16.933" />
<PackageVersion Include="Hi.Ltd.SQLite" Version="2024.4.16.933" />
<PackageReference Include="Hi.Ltd.SQLite" />
paket add Hi.Ltd.SQLite --version 2024.4.16.933
#r "nuget: Hi.Ltd.SQLite, 2024.4.16.933"
#:package Hi.Ltd.SQLite@2024.4.16.933
#addin nuget:?package=Hi.Ltd.SQLite&version=2024.4.16.933
#tool nuget:?package=Hi.Ltd.SQLite&version=2024.4.16.933
Hi.Ltd.SQLite
������Ҫ�� SQL SERVER���ݿ������ɾ�IJ鷽��ʵ��
��������C# �д�����ʱ�õ������Զ�Ӧ�����ݿ������ݱ�Ľṹ
�Զ����ѡ����
KeyAtrribute
KeyAtrribute ��ʾһ�ű�������������������� [Key] ��Ĭ��ѡ���� [Identity]����ѡ�� �Լ� [Reuired] ���ɿ�
[Key]
public int Id{get;set;}
DataBaseAttribute
DataBaseAttribute ��ʾһ�ű����ڵ����ݿ�����
[DataBase("Hi.Ltd")]
public class Table
{
}
TableAttribute
TableAttribute ��ʾһ�ű�����,����������ܣ�����Ҫ����Schema,����Ĭ��Ϊ"dbo"
[Table("Hi.Ltd")] //δָ��Schemaʱ��Ĭ�����ݿ��� dbo
public class Table
{
}
[Table("Hi.Ltd",Schema="hi")] //ָ��Schemaʱ����ָ����Schema�����ݿ��н���
public class Table
{
}
DatabaseGeneratedAttribute
DatabaseGeneratedAttribute ����ָ�������Ƿ�Ϊ�����У������ǰ����δ������Ĭ��Ϊ(Data.DatabaseGeneratedOption.Identity)�����У����������������������Ҫ�ֶ�����
[Key,DatabaseGenerated(Data.DatabaseGeneratedOption.None)]
public int Id{get;set;} //������һ������key �ɶԳ���
[Key,DatabaseGenerated(Data.DatabaseGeneratedOption.Identity)]
public int Id{get;set;} //���趨�� DatabaseGeneratedAttributeδָ��ʱЧ��һ��
MaxLengthAttribute
MaxLengthAttribute ����ָ���ַ����ڳ���,����ָ������Ĭ���ַ����ij���Ϊ50������洢�����ݿ���ֶ�ʵ�ʳ��ȳ���50�������ָ��
[MaxLength(450)]
public string Content{get;set;} //���ֶ����Ϊ450����Unicode�ַ���ʽ
public string Note{get;set;} // ���ֶ����Ϊ50����Unicode�ַ���ʽ ,�������쳣����ض��ַ�
RequiredAttribute
RequiredAttribute ����ָ����ǰ�ֶδ������ݿ����Ƿ����Ϊ��ֵ������ָ����Ĭ���ǿ���Ϊ��ֵ����ָ��������ֶα��벻��Ϊ��
[Required��MaxLength(450)]
public string Content{get;set;} //���ֶβ���Ϊ��
[MaxLength(450)]
public string Note{get;set;} //���ֶο���Ϊ��
ForeignKeyAttribute
ForeignKeyAttribute ����ָ���ӱ�������Ĺ�����Ϣ���Լ����������ɾ�������ʱ���Դӱ��Ӱ��
[Table("Master",Schema="dbo")]
public class MasterTable //����
{
[Key, DisplayName("���")]
public int Id { get; set; }
[DisplayName("����"), Required]
public DateTime DateTime { get; set; }
[DisplayName("����"), MaxLength(100)]
public string Name { get; set; }
[DisplayName("����"), MaxLength(450)]
public string Content { get; set; }
}
[Table("Slave",Schema="dbo")]
public class SlaveTable //�ӱ�
{
[Key, DisplayName("���")]
public int Id { get; set; }
[ForeignKey(typeof(MasterTable))]
public int MasterId { get; set; } //��MasterId�� Master����� Id����ӳ�����MasterId���ֵ������Master����� Id���еģ�����Ϊ��ֵ
[DisplayName("����"), Required]
public DateTime DateTime { get; set; }
[DisplayName("����"), MaxLength(100)]
public string Name { get; set; }
[DisplayName("����"), MaxLength(450)]
public string Content { get; set; }
}
[Table("Slave",Schema="dbo")]
public class SlaveTable //�ӱ�
{
[Key, DisplayName("���")]
public int Id { get; set; }
[ForeignKey(typeof(MasterTable),Option = TableDeleteOrUpdateOption.Cascade)]
public int MasterId { get; set; } //���δָ��Option��ֵ����Ĭ��Ϊ TableDeleteOrUpdateOption.Restrict,�� ����ӱ�����ƥ��ļ�¼,������������Ӧ��ѡ������update/delete����
[DisplayName("����"), Required] //������ó�TableDeleteOrUpdateOption.Cascade,�� ������update/delete��¼ʱ��ͬ��update/delete�ӱ��ƥ���¼
public DateTime DateTime { get; set; } //������ó�TableDeleteOrUpdateOption.Null,�� ��������update/delete��¼ʱ�����ӱ���ƥ���¼������Ϊnull
[DisplayName("����"), MaxLength(100)]
public string Name { get; set; }
[DisplayName("����"), MaxLength(450)]
public string Content { get; set; }
}
DigitAttribute
DigitAttribute ����ָ����������ΪDecimal���ֶΣ��������ݵij����Լ������С��λ��
[Digit(10,2)]
public decimal PressDecimal{get;set;} //��δָ������Ĭ��Ϊ Digit(18,0)
��������
��������ʾ���ݱ�ʾ��
[Table("Navigation", Schema = "dbo"), DisplayName("������")]
public class NavigationTable
{
[Key, DisplayName("���")]
public int Id { get; set; }
[DisplayName("����")]
public DateTime DateTime { get; set; }
[MaxLength(450), DisplayName("����")]
public string Content { get; set; }
[MaxLength(450), DisplayName("��ע")]
public string Note { get; set; }
}
[Table("Login", Schema = "dbo"),DisplayName("��¼��")]
public class Login : BaseTable
{
[Key, DisplayName("���")]
public int Id { get; set; }
[Required, DisplayName("����")]
public DateTime DateTime { get; set; }
[MaxLength(250),DisplayName("�û���")]
public string UserName { get; set; }
[MaxLength(250),DisplayName("����")]
public string Password { get; set; }
[ForeignKey(typeof(NavigationTable)),DisplayName("�������")]
public int NavigationId { get; set; }
}
CreateDatabase
CreateDatabase ��ʾ����һ�����ݿ⣬�����ǰ���ݿⲻ����������������
var sql = SqlEntities.Create; //�����������
sql.DataSource = "(local)"; //��д���ݿ����������ǰ����Ϊ����
sql.UserId = "sa"; //��д�û������� �û��������벻��д����Ĭ��Ϊ���ص�¼
sql.Password = "Demo123456"; //�����,
sql.Database = "Hi.Ltd"; //ָ�����ݿ����ƣ�����ָ�����ݿ����ƣ����������ÿ�ű��趨ʱָ�����ݿ�����
sql.Timeout = 10; //�������ӳ�ʱʱ�䣨S�����粻�趨����Ĭ��Ϊ15S
sql.Connection(); �������ӵ����ݿ⣬������ӳɹ��� true, ���� ���� false;
//�������ݿ�
sql.CreateDatabase(sql.Database); //����ָ��·������Ĭ�ϴ洢�� "C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA" �ļ�����
//�����������ݿ�洢��ָ��λ��
sql.CreateDatabase(sql.Database,@"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA");
CreateTable
CreateTable ��ʾ����һ�����ݱ�������ǰ���ݱ������ݿ����Ѿ�����������������һ���µ����ݱ�
sql.CreateTable<NavigationTable>(); //����������
//��ָ�����ݿ��д���������
sql.CreateTable<NavigationTable>("Hi.Ltd"); //���������ı������ݿ�����ʾΪ [Hi.Ltd].[dbo].[Navigation] ,���NavigationTable ��δָ��Table���ԣ��������ݿ�����ʾΪ[Hi.Ltd].[dbo].[NavigationTable]
//��ָ�����ݿ���ʹ���µ�����������������
sql.CreateTable<NavigationTable>("Hi.Ltd","NewNavigation"); //���������ı������ݿ�����ʾΪ [Hi.Ltd].[dbo].[NewNavigation]
//��ָ�����ݿ���ʹ���µ�����,�µļܹ�������������
sql.CreateTable<NavigationTable>("Hi.Ltd","NewNavigation","hi"); //���������ı������ݿ�����ʾΪ [Hi.Ltd].[hi].[NewNavigation]
sql.CreateTable<Login>(); //������¼�� ����������ʹ��ͬ��
AlterTable
AlterTable ��ʾ�Ա�ṹ�����ĵ���ز������˲�������һ���ķ��գ�ֻ���ڲ��Ի�����ʹ�ã���ʽ�����²�����ʹ�ã��˲���������ת����ɾ�����һ�
sql.AlterTable<NavigationTable>(); //�˷����������ݿ��е� [Hi.Ltd].[dbo].[Navigation] ���бȶԣ�����б��Ա���Ʋ�ͬ������ڴ˱�������һ�����ݡ�
//���������ͬ���������Ͳ�ͬ�����ı��Ӧ��Ա���������ͣ�
//��ָ�����ݿ����ĵ�����
sql.AlterTable<NavigationTable>("Hi.Ltd");
sql.AlterTable<NavigationTable>("Hi.Ltd","NewNavigation");
sql.AlterTable<NavigationTable>("Hi.Ltd","NewNavigation","hi");
sql.RenameColumn<NavigationTable>("Hi.Ltd","NewNavigation","hi","Note","NewNote"); //���������[Note]��� [NewNote] ;
sql.DropColumn<NavigationTable>("Hi.Ltd","Navigation","hi","Note"); //�����е�����[Note]�ӱ����Ƴ����˲����������أ�����Ҫ�Ƴ�����ȷ���Ƴ���ǰ���ݶԳ����������û���κ�Ӱ��;
sql.RenameTable<NavigationTable>("Navigation","NewNavigation"); //����������[Navigation]���Ϊ[NewNavigation]
BackupDatabase
BackupDatabase ��һ���Ѿ����ڵ����ݿ���б��ݲ�������ָ�������ݲ����ڣ�������
sql.BackupDatabase("Hi.Ltd"); //�粻ָ���洢·����Ĭ�ϴ洢��"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup"�ļ��£�
//����ָ���ļ����ƣ���ָ�������ݿ������������ ��Hi.Ltd.bak
sql.BackupDatabase("Hi.Ltd",@"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup");
sql.BackupDatabase("Hi.Ltd",@"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup","backup");
RestoreDatabase
RestoreDatabase ��ָ���Ĵ洢·����ԭ���ݿ�
sql.RestoreDatabase("Hi.Ltd",@"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup","backup"); //�粻ָ���洢·����Ĭ�ϴ洢��"C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup"�ļ��£�
//TODO:��������������
InsertTable
InsertTable �����ݱ������һ�����ݣ���������������
//��ʼһ������,����Id�����ݿ������������������Բ���Ҫ���ã���û�������������������Idֵ
var content=new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������",
Note=string.Empty
};
//��ʼ����������
var content=new List<NavigationTable>()
{
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������1",
Note=string.Empty
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������2",
Note=string.Empty
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������3",
Note=string.Empty
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������4",
Note=string.Empty
}
}��
sql.InsertTable(content); //�����ݿ��в���һ������
//��ָ�����ݿ�����ݱ��в���һ������
sql.InsertTable("Hi.Ltd",content);
//��ָ�����ݿ��ָ�����ݱ��в���һ������
sql.InsertTable("Hi.Ltd","NewNavigation",content);
//��ָ�����ݿ��ָ���ܹ���ָ�����ݱ��в���һ������
sql.InsertTable("Hi.Ltd","NewNavigation","hi",content);
sql.InsertTable(contents); //�����ݿ��в���4������ ,����ͬ��
UpdateTable
UpdateTable �����ݱ������һ�����ݣ���������������
//��ʼһ������,���ڸ������ݱ���ָ��Ψһ������������ȷ�����������Ǹ��µ�����
var content=new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������",
Note=string.Empty��
Id=1
};
//��ʼ����������
var content=new List<NavigationTable>()
{
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������1",
Note=string.Empty,
Id=2
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������2",
Note=string.Empty,
Id=3
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������3",
Note=string.Empty,
Id=4
},
new NavigationTable(){
DateTime=DateTime.Now,
Name="����һ��������4",
Note=string.Empty,
Id=5
}
}��
sql.UpdateTable(content); //�����ݿ��и���һ������
//��ָ�����ݿ�����ݱ��и���һ������
sql.UpdateTable("Hi.Ltd",content);
//��ָ�����ݿ��ָ�����ݱ��и���һ������
sql.UpdateTable("Hi.Ltd","NewNavigation",content);
//��ָ�����ݿ��ָ���ܹ���ָ�����ݱ��и���һ������
sql.UpdateTable("Hi.Ltd","NewNavigation","hi",content);
sql.UpdateTable(contents); //�����ݿ��и���4������ ,����ͬ��
//TODO ���������������������ݱ� ��ʵ���У����ڴ˲������չ����Ƽ�ʹ��
InqureTable
InqureTable ������������ѯ����
//Ĭ�ϲ�ѯ���µ�ǰ1000����¼
sql.InqureTable<NavigationTable>();
//��ָ�����ݿ�����ݱ��и���һ������
sql.InqureTable<NavigationTable>("Hi.Ltd");
//��ָ�����ݿ��ָ�����ݱ��и���һ������
sql.InqureTable<NavigationTable>("Hi.Ltd","NewNavigation");
//��ָ�����ݿ��ָ���ܹ���ָ�����ݱ��и���һ������
sql.InqureTable<NavigationTable>("Hi.Ltd","NewNavigation","hi");
//TODO ��������ѯ����ʵ����
DropTable
DropTable �����ݿ���ɾ��ָ���ı�
//�����ݿ���ɾ����
sql.DropTable<NavigationTable>();
//��ָ�����ݿ�ɾ����
sql.DropTable<NavigationTable>("Hi.Ltd");
//��ָ�����ݿ���ɾ��ָ�����ݱ�
sql.DropTable<NavigationTable>("Hi.Ltd","NewNavigation");
//��ָ�����ݿ���ɾ��ָ���ܹ���ָ�����ݱ�
sql.DropTable<NavigationTable>("Hi.Ltd","NewNavigation","hi");
DeleteTable
DeleteTable �����ݱ���ɾ��ָ��������
//TODO ������ɾ������ʵ����
�������Ѿ���ɲ��Ҳ���OK�Ĺ��ܣ���ʵ�ֵĹ��������ݱ����ݰ�����ɾ����������飬������ģ������ɾ�
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 is compatible. net471 is compatible. net472 was computed. net48 is compatible. net481 is compatible. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hi.Ltd.SQLite:
| Package | Downloads |
|---|---|
|
Hi.Ltd.LocalResource
此类库主要用于文本内容翻译 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.6.10.1451 | 99 | 6/10/2026 |
| 2026.4.14.1758 | 111 | 4/14/2026 |
| 2026.4.14.1613 | 108 | 4/14/2026 |
| 2025.4.17.1101 | 263 | 4/17/2025 |
| 2025.4.16.1536 | 252 | 4/16/2025 |
| 2025.4.16.1410 | 243 | 4/16/2025 |
| 2024.4.16.933 | 262 | 4/16/2025 |
用于处理Sqlite数据库相关方法操作