66</p >
77
88<p align =" center " >
9- <a aria-label =" stable-release-version " href =" https://www.nuget.org/packages/Fly.SQL/1.0.1 " target =" _blank " >
9+ <a aria-label =" stable-release-version " href =" https://www.nuget.org/packages/Fly.SQL/1.0.2 " target =" _blank " >
1010 <img alt="FlySQL Stable Release" src="https://img.shields.io/nuget/v/Fly.SQL.svg?style=flat-square&label=Stable&labelColor=000000&color=0ea5e9" />
1111 </a >
1212 <a aria-label =" FlySQL is free to use " href =" https://github.com/jdmay2/FlySQL/blob/main/LICENSE " target =" _blank " >
@@ -29,42 +29,42 @@ A simple ORM for the MySql.Data NuGet package to use in any projects allowing fo
2929
3030### NuGet Package Manager
3131
32- ```
32+ ``` cmd
3333 Install-Package Fly.SQL
3434```
3535
3636### .NET CLI
3737
38- ```
38+ ``` cmd
3939 dotnet add package Fly.SQL
4040```
4141
4242### Package Reference
4343
4444``` csharp
45- < PackageReference Include = " Fly.SQL" Version = " 1.0.1 " / >
45+ < PackageReference Include = " Fly.SQL" Version = " 1.0.2 " / >
4646```
4747
4848### Packet CLI
4949
50- ```
50+ ```cmd
5151 paket add Fly .SQL
5252```
5353
5454### Script & Interactive
5555
56- ```
57- #r "nuget: Fly.SQL, 1.0.1 "
56+ ```cmd
57+ #r "nuget: Fly.SQL, 1.0.2 "
5858```
5959
6060### Cake
6161
62- ```
62+ ```cmd
6363 // Cake Addin
64- #addin nuget:?package=Fly.SQL&version=1.0.1
64+ #addin nuget:?package=Fly.SQL&version=1.0.2
6565
6666 // Cake Tool
67- #tool nuget:?package=Fly.SQL&version=1.0.1
67+ #tool nuget:?package=Fly.SQL&version=1.0.2
6868```
6969
7070## Package Layout
@@ -73,7 +73,7 @@ A simple ORM for the MySql.Data NuGet package to use in any projects allowing fo
7373
7474- ### **[`SQL `](#set - up - file )**
7575- [`Connect (string connection - string )`](#connection - example )
76- - [`Query (string connection - string )`](#query - example )
76+ - [`Query (string statement )`](#query - example )
7777- [`Read ()`](#reader - example )
7878- [`Study ()`](#read - example )
7979
@@ -91,6 +91,8 @@ A simple ORM for the MySql.Data NuGet package to use in any projects allowing fo
9191> Same as above , but for possible null values. Condensed versions of MySqlDataReader null checks for incoming values (IsDBNull).
9292
9393- `NString (int )`
94+ - Returns `" " ` if null
95+ - `NStrung (int )`
9496 - Returns null if null
9597- `NInt (int )`
9698 - Returns 0 if null
@@ -107,17 +109,9 @@ A simple ORM for the MySql.Data NuGet package to use in any projects allowing fo
107109- `NBool (int )`
108110 - Returns false if null
109111
110- > [The Add method is used to add parameters to the SQL query . It currently accepts the types listed below the method .](#add - example )
112+ > [The Add method is used to add parameters to the SQL query . It accepts any input types the same as AddWithValue () would accept .](#add - example )
111113
112- - [`Add (string param , string value )` (+ 8 Overloads )](#full - add - example )
113- - `string `
114- - `int `
115- - `long `
116- - `double `
117- - `float `
118- - `decimal `
119- - `DateTime `
120- - `bool `
114+ - [`Add (string param , object value )`](#full - add - example )
121115
122116> The Close method simply closes the connection to the database . The Finish method is used to prepare and execute other queries .
123117
@@ -126,11 +120,17 @@ A simple ORM for the MySql.Data NuGet package to use in any projects allowing fo
126120
127121### **[`Quick Queries`](#quick-query-examples)**
128122
123+ - [`Query (string statement , string param , object value )`](#quick - query - example )
129124- [`Select (string table )`](#select - example )
130125- [`Select (string table , string target )`](#select - single - example )
126+ - [`Select (string table , string target , object value )`](#select - single - value - example )
131127- [`Insert (string table , params string [] columns )`](#insert - example )
128+ - [`OneInsert (string table , params object [] values )`](#one - insert - example )
132129- [`Update (string table , string target , params string [] columns )`](#update - example )
130+ - [`OneUpdate (string table , string target , object targetValue , params object [] values )`](#one - update - example )
133131- [`Delete (string table , string target )`](#delete - example )
132+ - [`Delete (string table , string target , object value )`](#delete - single - example )
133+ - [`Mad (params object [] values )`](#mad - example )
134134- [`Bulk (params object [] values )`](#insert - example )
135135
136136### **Full Examples**
@@ -157,7 +157,7 @@ Add the using statement and SQL base class to setup the file for use of the pack
157157
158158<h3 id ="connection -example ">Setting the Connection String </h3 >
159159
160- #### v1.0.1
160+ #### As of v1.0.1
161161
162162```csharp
163163 public User Get (int id )
@@ -386,7 +386,7 @@ Add the using statement and SQL base class to setup the file for use of the pack
386386
387387> Quick queries are used to simplify basic sql statements even further and are used in the following examples .
388388
389- < h3 id = " select- example" > Select Example < / h3 >
389+ < h3 id = " quick-query- example" > Query Example < / h3 >
390390
391391```csharp
392392 using FlySQL ;
@@ -397,9 +397,46 @@ Add the using statement and SQL base class to setup the file for use of the pack
397397 {
398398 Connect (" connection-string" );
399399
400+ // users and courses are just sample entities
401+ Query (@" SELECT * FROM courses WHERE courseId IN (SELECT courseId FROM course_students WHERE userId=@userId)" , " userId" , id );
402+ // The Query(stm, param, value) method is used for if you have a more complex query with only one parameter
403+ // The parameter is added within the method
404+
405+ Read ();
406+
407+ // User is just a sample entity
408+ List < User > users = new List <User >();
409+ while (Study ())
410+ {
411+ users .Add (new User ()
412+ {
413+ Id = Int (0 ),
414+ Username = String (1 ),
415+ Name = String (2 ),
416+ });
417+ }
418+
419+ Close ();
420+ return users ;
421+ }
422+ }
423+ ```
424+
425+ <h3 id = " select-example" > Select Example < / h3 >
426+
427+ ```csharp
428+ using FlySQL ;
429+
430+ public class ReadUsers : SQL
431+ {
432+ public List <User > Get ()
433+ {
434+ Connect (" connection-string" );
435+
436+ // User is just a sample entity
400437 Select (" users" );
401438 // SELECT * FROM users
402- /* similar to Query(); but without the need to write the SQL statement, just put the table name if you want to select all */
439+ // similar to Query(); but without the need to write the SQL statement, just put the table name if you want to select all columns
403440
404441 Read ();
405442
@@ -414,9 +451,9 @@ Add the using statement and SQL base class to setup the file for use of the pack
414451 Name = String (2 ),
415452 });
416453 }
417- return users ;
418454
419455 Close ();
456+ return users ;
420457 }
421458 }
422459```
@@ -432,6 +469,7 @@ Add the using statement and SQL base class to setup the file for use of the pack
432469 {
433470 Connect (" connection-string" );
434471
472+ // User is just a sample entity
435473 Select (" users" , " userId" );
436474 // SELECT * FROM users WHERE userId=@userId
437475 /* similar to Query(); but without the need to write the SQL statement, just put the table name and the target column name if you want to select a single value */
@@ -456,6 +494,38 @@ Add the using statement and SQL base class to setup the file for use of the pack
456494 }
457495```
458496
497+ <h3 id = " select-single-value-example" > Select Single With Value Example < / h3 >
498+
499+ ```csharp
500+ using FlySQL ;
501+
502+ public class ReadUser : SQL
503+ {
504+ public User Get (int id )
505+ {
506+ Connect (" connection-string" );
507+
508+ // User is just a sample entity
509+ Select (" users" , " userId" , id );
510+ // SELECT * FROM users WHERE userId=@userId
511+ // Just like Select(table, target) but the target value added and no need to use Add()
512+
513+ Read ();
514+
515+ // User is just a sample entity
516+ Study ();
517+ return new User ()
518+ {
519+ Id = Int (0 ),
520+ Username = String (1 ),
521+ Name = String (2 ),
522+ };
523+
524+ Close ();
525+ }
526+ }
527+ ```
528+
459529<h3 id = " insert-example" > Insert Example < / h3 >
460530
461531```csharp
@@ -490,6 +560,26 @@ Add the using statement and SQL base class to setup the file for use of the pack
490560 }
491561```
492562
563+ <h3 id = " one-insert-example" > OneInsert Example < / h3 >
564+
565+ ```csharp
566+ using FlySQL ;
567+
568+ public class AddUser : SQL
569+ {
570+ public void Add (User user )
571+ {
572+ Connect (" connection-string" );
573+ // Assume id is an integer and auto-incrementing
574+ // User is just a sample entity
575+ OneInsert (" users" , " username" , user .Username , " name" , user .Name );
576+ // table name, param pairs
577+ // INSERT INTO users (username, name) VALUES (@username, @name)
578+ // Will auto run Finish() after OneInsert is called, assuming that all values have been added in the OneInsert() method
579+ }
580+ }
581+ ```
582+
493583<h3 id = " update-example" > Update Example < / h3 >
494584
495585```csharp
@@ -518,6 +608,25 @@ Add the using statement and SQL base class to setup the file for use of the pack
518608 }
519609```
520610
611+ <h3 id = " one-update-example" > OneUpdate Example < / h3 >
612+
613+ ```csharp
614+ using FlySQL ;
615+
616+ public class EditUser : SQL
617+ {
618+ public void Edit (User user )
619+ {
620+ Connect (" connection-string" );
621+ // User is just a sample entity
622+ OneUpdate (" users" , " userId" , user .Id ," username" , user .Username , " name" , user .Name );
623+ // table name, target name, target value, param pairs ...
624+ // UPDATE users SET username=@username, name=@name WHERE userId=@userId
625+ // Will auto run Finish() after OneUpdate is called, assuming that all values have been added in the OneUpdate() method
626+ }
627+ }
628+ ```
629+
521630<h3 id = " delete-example" > Delete Example < / h3 >
522631
523632```csharp
@@ -539,6 +648,53 @@ Add the using statement and SQL base class to setup the file for use of the pack
539648 }
540649```
541650
651+ <h3 id = " delete-single-example" > Delete With Value Example < / h3 >
652+
653+ ```csharp
654+ using FlySQL ;
655+
656+ public class DeleteUser : SQL
657+ {
658+ public void Delete (int id )
659+ {
660+ Connect (" connection-string" );
661+ // User is just a sample entity
662+ Delete (" users" , " userId" , id );
663+ // table name, target name, target value
664+ // DELETE FROM users WHERE userId=@userId
665+ // Will auto run Finish() after Delete() is called
666+ }
667+ }
668+ ```
669+
670+ <h3 id = " mad-example" > Mad Example < / h3 >
671+
672+ ```csharp
673+ using FlySQL ;
674+
675+ // Does not have to just be edit, this is just an example to show how to use the method
676+
677+ public class EditUser : SQL
678+ {
679+ public void Edit (User user )
680+ {
681+ Connect (" connection-string" );
682+ // User is just a sample entity
683+ Update (" users" , " userId" , " username" , " name" );
684+ // table name, target name, column name, column name, ...
685+ // UPDATE users SET username=@username, name=@name WHERE userId=@userId
686+
687+ // Add parameters
688+ Mad (" @username" , user .Username , " @name" , user .Name , " @userId" , user .Id );
689+ // Similar to Bulk() but does not auto Finish()
690+ // Add() can be used before and after Mad()
691+ // Mad() will throw an error if the number of parameters is not even, but there is not a limit to the number of parameters you can add
692+
693+ Finish (); // prepare statement and execute
694+ }
695+ }
696+ ```
697+
542698## License
543699
544700The FlySQL source code is made available under the [MIT license ](https:// github.com/jdmay2/FlySQL/blob/main/LICENSE).
0 commit comments