RepoDb promises to be the hybrid ORM for .NET. Even though RepoDb supports both Dynamic and Fluent operations, but currently, RepoDb fluent implementation seems to be limited to an Entity Model.
This story would allow the library consumer to use the model (or a DataEntity class) to any table from the database. The intention is, if you have a table with an identical columns with other tables, then you can utilize single model for that.
See the sample code below.
Let us say, you have a Person like below.
CREATE TABLE [dbo].[Person]
(
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](128) NOT NULL,
[Age] [int] NOT NULL,
[CreatedDateUtc] [datetime2](5) NOT NULL,
CONSTRAINT [CRIX_Person_Id] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]
)
ON [PRIMARY];
GO
And a Customer table like below.
CREATE TABLE [dbo].[Customer]
(
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](128) NOT NULL,
[Age] [int] NOT NULL,
[CreatedDateUtc] [datetime2](5) NOT NULL,
CONSTRAINT [CRIX_Customer_Id] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]
)
ON [PRIMARY];
GO
Then, you create a class below.
public class PersonOrCustomer
{
public long Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public DateTime CreatedDateUtc { get; set; }
}
You should be able to query it like below. See the code for the Person table.
var people = connection.Query<PersonOrCustomer>("Person");
And Customer table.
var people = connection.Query<PersonOrCustomer>("Customer");
You should be able to insert it like below. See the code for the Person table.
var people = connection.Insert("Person", new PersonOrCustomer { Name = "John Doe" });
And Customer table.
var people = connection.Insert("Customer", new PersonOrCustomer { Name = "James Smith" });
You should be able to merge it like below. See the code for the Person table.
var people = connection.Merge("Person", new PersonOrCustomer { Id = 10045, Name = "James Doe" });
And Customer table.
var people = connection.Merge("Customer", new PersonOrCustomer { Id = 11011, Name = "John Smith" });
You should be able to merge it like below. See the code for the Person table.
var people = connection.Update("Person", new PersonOrCustomer { Id = 10045, Address = "New York" });
And Customer table.
var people = connection.Update("Customer", new PersonOrCustomer { Id = 11011, Address = "New York" });
The extent of the changes must be on all operations available in RepoDb library.
Need to add more Integration Tests for QueryAll method and also to all Async methods. In addition, need to create an overloaded methods for the targeted where arguments (i.e.: Expression-Based, QueryField, IEnumerable
@isaacabraham - I will include your request on this User Story. This is exactly what you are looking in F#.
The changes are done by now, but we need to add more integration tests before the beta release.
Last commit was for 'DeleteAll' integration tests.
Added more Integration Tests for Insert operation. Reference: https://github.com/mikependon/RepoDb/commit/f974fc4bf960979e620b3599dac018e272997c03
Closing this ticket now.
Most helpful comment
@isaacabraham - I will include your request on this User Story. This is exactly what you are looking in F#.