This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSERT INTO dbo.Categories (CategoryName, Description) | |
| VALUES (@CategoryName, @Description) | |
| SELECT SCOPE_IDENTITY() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INSERT INTO SCOTT.DEPT (DNAME, LOC, DEPTNO) | |
| VALUES (:DNAME, :LOC, SCOTT.DEPT_SEQ.nextval); | |
| SELECT SCOTT.DEPT_SEQ.currval FROM DUAL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Film | |
| { | |
| // the primary key | |
| public int Id; | |
| public string Title; | |
| public string Description; | |
| // DB column has default of the current date-time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.Insert(new Film("Star Wars", "A long time ago….")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var films = new MightyOrm<Film>(connectionString); | |
| var film = films.New(new { | |
| Title = "Star Wars", | |
| Description = "A long time ago..." | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var db = new MightyOrm(connectionString, "Film", "FilmID"); | |
| var film = db.Single(47); | |
| film.Description = "This is a better description"; | |
| db.Save(film); | |
| var films = db.All(new { Director = "Spielberg" }); | |
| foreach (var film in films) Console.WriteLine(film.Title); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var result = db.ExecuteProcedure("my_add_proc", inParams: new { a = 1, b = 2}, outParams: new { c = (int?)null }); | |
| Console.WriteLine(result.c); // 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var db = new MightyOrm<Film>(connectionString, primaryKeys: "FilmID"); | |
| var films = db.All(); | |
| foreach (Film film in films) | |
| { | |
| Console.WriteLine($"{film.Title}: {film.Description}"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [DatabaseTable("films")] | |
| public class Film | |
| { | |
| [DatabaseColumn("film_id")] | |
| public int FilmID; | |
| [DatabaseColumn("film_title")] | |
| public int Title; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var db = new MightyOrm(connectionString); | |
| var now = DateTime.Now; | |
| using (var multiple = db.ExecuteMultipleFromProcedure("PurchaseReport", | |
| inParams: new { StartDate = now.AddMonths(6), EndDate = now }) | |
| { | |
| multiple.NextResultSet(); | |
| foreach (var summary in multiple.CurrentResultSet.ResultsAs<PurchaseReportSummary>()) | |
| { | |
| Console.WriteLine($"Total Sales for Report Period: ${summary.Total}"); | |
| } |