Preface

Firebird Is a cross platform relational database system , At present, it can run in Windows、linux And all kinds of Unix On the operating system , Provides most of SQL-99 Standard functions . It can run as a database server in a multi-user environment , It also provides the implementation of embedded database .

Firebird Born out of Borland The company's open source database Interbase6.0, It is a completely non-commercial product , use C and C++ Development . Because of and interbase By blood , Most of the interbase Our development tools can be directly applied to Firebird In development .Firebird Use Mozilla Public License v.1.1 License issue .

FreeSql Support Firebird embedded database , And Sqlite It also belongs to the local database , And the reliability is stronger than sqlite, Database file however 10 mega size .

1、 Installation environment

Database environment :Firebird ( Embedded version )

Download address :https://firebirdsql.org/en/server-packages/

.NET edition :.net6.0

Download address :https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install

Developing machines :windows 10

2、 Create project

We use console Type project test Insert 、 Delete 、 to update 、 Inquire about And so on , Create a console project , Use command :

dotnet new console

dotnet add package FreeSql.Provider.Firebird

dotnet add package FreeSql.Repository

3、 Create a solid model

using System;
using FreeSql.DataAnnotations; [Table(Name = "USER_FIREBIRD")]
public class User
{
[Column(IsIdentity = true)]
public long Id { get; set; } public string UserName { get; set; } public string PassWord { get; set; } public DateTime CreateTime { get; set; }
}

4、 initialization ORM

static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.Firebird,
@"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=3")
.UseMonitorCommand(cmd => Trace.WriteLine($" Threads :{cmd.CommandText}\r\n"))
.UseAutoSyncStructure(true) // Automatically create 、 Migrate entity table structure
.UseNameConvert(NameConvertType.ToUpper)
.Build();

5、 insert data

var repo = fsql.GetRepository<User>();

var user = new User { UserName = "gaussdb1", PassWord = "123" };
repo.Insert(user);

First access to automatically create tables

var users = new []
{
new User { UserName = "gaussdb2", PassWord = "1234" },
new User { UserName = "gaussdb3", PassWord = "12345" },
new User { UserName = "gaussdb4", PassWord = "123456" }
};
repo.Insert(users);
// Batch insert

Due to primary key ID It's self increasing , This batch insertion will be split into multiple executions , And backfill the value users[0..2].Id

6、 Update data

user.PassWord = "123123";
repo.Update(user);

Only update changed attributes ( Field )

7、 Query data

var one = fsql.Select<User>(1).First(); // Query a piece of data 

var list = fsql.Select<User>().Where(a => a.UserName.StartsWith("gaussdb")).ToList();

8、 Delete data

fsql.Delete<User>(1).ExecuteAffrows();

fsql.Delete<User>().Where(a => a.UserName.StartsWith("gaussdb")).ExecuteAffrows();

Conclusion

This article gives a brief introduction to .net6.0 Use in the environment FreeSql Yes Firebird Database access , at present FreeSql And support .net framework 4.0 and xamarin On the platform .

except Add or delete check change ,FreeSql It also supports many functions , Not one by one , There is no end to an article .

FreeSql yes .NETCore/.NetFramework/Xamarin Under the platform ORM Open source project , Support SqlServer/MySql/PostgreSQL/Oracle/Sqlite/Firebird/Clickhouse/ Reach a dream / Supernatural power / Jincang / Hangao , And Huawei GaussDB database , In the future, more domestic databases will be connected to support .

Source code address :https://github.com/2881099/FreeSql

Thank you for your support !

[ Open source ] .Net ORM visit Firebird More articles on the database

  1. Python With the database [2] -&gt; Relational object mapping /ORM[3] -&gt; sqlalchemy Declaration layer ORM access

    sqlalchemy Declaration layer ORM access sqlalchemy You can use the declaration layer to create table classes , And make use of ORM Object to operate and access the database , The other way is explicit ORM access . The main establishment steps include : ...

  2. Python With the database [2] -&gt; Relational object mapping /ORM[4] -&gt; sqlalchemy Explicit expression of ORM access

    sqlalchemy Explicit expression of ORM access about sqlalchemy, We can take advantage of an explicit ORM Way to visit , This approach does not rely on the declaration layer , It's an explicit operation . Another way to access it is the declaration layer ORM access . ...

  3. C++ edition ORM Access to the database ODB Of Window Environment compilation ( One )

    First, let's briefly talk about why I want to compile a ORM Access the version of the database , I used to do C# When accessing the database , Directly to orm How to access the database , The code is simple to write ,  Don't write all kinds of complicated sql sentence , Directly orm Frame generation , Later, I turned to C+ ...

  4. C++ edition ORM Access to the database ODB Of oracle Demo test ( Two )

    It has been said in the last article odb Compiler environment , Now take the example directly to test the operation of adding, deleting, modifying and querying the database 1. ODB visit oracle database _ The insert (insert) Run the compiled in the previous article directly exe The following error will appear in the file wrong ...

  5. [ Open source ] .Net ORM FreeSql 1.10.0 Go steadily

    Written in the beginning FreeSql yes .NET Open source ecosystem ORM wheel , It's almost two years now , To be honest, open source is not easy ( Only through experience can we understand ). Bring some dry and wet goods to everyone today , First, wet goods . People who know me , know CSRedisCore ...

  6. Use SQLAlchemy Yes Firebird Database operation

    I've been in this company for a week , After the boring days, I'm ready to do something , I have contacted the file database these days InterBase, Try to Ubuntu Connect to its open source version Firebird, Because the company uses SQLAlchemy ...

  7. 【Android】13.0 The first 13 Chapter Create and access SQLite database &mdash; This chapter shows the main interface

    classification :C#.Android.VS2015: Date of creation :2016-02-26 One . brief introduction Android Three data access modes are built in :SQLite database . file .SharedPreferences. In this chapter we ...

  8. Firebird Database related memo

    Firebird There are some very special things in the database , useful , But because I don't use much at ordinary times , Here it is , For future use and inquiry . 1. With ADO Of OLE ODBC Drive mode access Firebird, You can use the following connection string : FBCon ...

  9. Python course :ORM Connect Sqlite database , Software architecture foundation

    python Language is easy to learn because of its simple grammar , High efficiency and wide application , It has developed rapidly in recent years , Once in the top six programming languages . In order to make programmers learn faster Python Language , So I wrote this tutorial . It can also be said that it is a summary of one's own learning . But the article tries to make ...

  10. .Net Open source SqlServer ORM frame SqlSugar Arrangement

    One . Link collation official Git Source code address : https://github.com/sunkaixuan/SqlSugar Update address for the latest release : current version Release 3.5.2.1 https://gith ...

Random recommendation

  1. apache commons math Sample code

    apache commons Math It's a set of functions that are biased towards scientific computation , Mainly for linear algebra , Mathematical analysis , Probability and statistics, etc . Although I graduated from mathematics , I was holding < Mathematical analysis > chew , But not for a long time , These general ...

  2. Large scale website system architecture practice ( Four )http Layer load balancing haproxy Practice chapter ( One )

    programme The last article talked about the relevant theoretical knowledge of load balancing , In this article, I'm going to talk about practical methods and problems encountered in practice programme :haproxy http Layer load balancing To install a haproxy service , Two web service haproxy:192 ...

  3. pure CSS Create a triangle

    [ requirement ]: In pure CSS What is the principle of creating a triangle ? * answer : Put it on . Left . The three right edges are hidden ( Set the color to transparent) [ Realization ]: #demo { width: 0; height: 0; bord ...

  4. Regex example

    Password complexity : Numbers, English symbols Regex r = new Regex("^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])|(?=.*[A-Z])(?=.*[a-z])(? ...

  5. look around My97DatePicker Source code J Method

    If there is a path written wrong and the path is written in the front , So relevant css You don't want to bring in the documents <script language="javascript" type="text ...

  6. BZOI 1507 [NOI2003] Editor

    Background After trying to solve problem EDIT1(Editor) and being ****ed by Brainf**k, Blue Mary deci ...

  7. python Package download address

    https://www.lfd.uci.edu/~gohlke/pythonlibs/

  8. Super simple Android Studio jni Realization ( There's no command line )【 Reprint 】

    original text : http://www.jianshu.com/p/e689d0196a17 1. To configure Anroid Studio( This step is the key ) Use [command+,] open Preferences, choice Ext ...

  9. ActiveReports Big data analysis report :2018 Chinese film has ushered in the golden age again

    review 2018, The Chinese film market has gained a lot . First, with the Spring Festival file < The red sea action >.< Chinatown detective > Both realize 30 Billion box office breakthrough , And then the fire is on in the summer ,< I'm not a druggist >.< Xihong city's richest man > ...

  10. pyqt5- Keyboard events

    Video tutorial :https://v.qq.com/x/page/p08592bhsag.html keyPressEvent(QKeyEvent)     Call when the keyboard is pressed keyReleaseEvent(QK ...