added core classes
This commit is contained in:
parent
3c6e421dbf
commit
e919026502
@ -1,30 +1,57 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace COA.EnterpriseServices.DataAccess.EntityFramework
|
namespace COA.EnterpriseServices.DataAccess.EntityFramework
|
||||||
{
|
{
|
||||||
public class EntityDataAccess<T> : IDataAccess<T> where T : IRecord
|
public class EntityDataAccess<T> : IDataAccess<T> where T : class, IRecord
|
||||||
{
|
{
|
||||||
public bool Add(T item)
|
public bool Add(T item)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using (var context = new QuickBaseContext())
|
||||||
|
{
|
||||||
|
context.Add(item);
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(T item)
|
public bool Update(T item)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using (var context = new QuickBaseContext())
|
||||||
|
{
|
||||||
|
context.Entry(item);
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICollection<T> Get(int id)
|
public ICollection<T> Get(int id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using (var context = new QuickBaseContext())
|
||||||
|
{
|
||||||
|
return context
|
||||||
|
.Set<T>()
|
||||||
|
.Where(r => r.Id == id)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICollection<T> Get(Expression<Func<T, bool>> query)
|
public ICollection<T> Get(Expression<Func<T, bool>> query)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
using (var context = new QuickBaseContext())
|
||||||
|
{
|
||||||
|
return context
|
||||||
|
.Set<T>()
|
||||||
|
.Where(query)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
COA.EnterpriseServices.DataAccess.EntityFramework/Migrations/20201014010244_initial.Designer.cs
generated
Normal file
37
COA.EnterpriseServices.DataAccess.EntityFramework/Migrations/20201014010244_initial.Designer.cs
generated
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using COA.EnterpriseServices.DataAccess.EntityFramework;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(QuickBaseContext))]
|
||||||
|
[Migration("20201014010244_initial")]
|
||||||
|
partial class initial
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
|
modelBuilder.Entity("COA.EnterpriseServices.DataAccess.EntityFramework.Entities.Creditor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Creditors");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||||
|
{
|
||||||
|
public partial class initial : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Creditors",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Creditors", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Creditors");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using COA.EnterpriseServices.DataAccess.EntityFramework;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(QuickBaseContext))]
|
||||||
|
partial class QuickBaseContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.9")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
|
modelBuilder.Entity("COA.EnterpriseServices.DataAccess.EntityFramework.Entities.Creditor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Creditors");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,13 @@ namespace COA.EnterpriseServices.DataAccess.EntityFramework
|
|||||||
{
|
{
|
||||||
public class QuickBaseContext : DbContext
|
public class QuickBaseContext : DbContext
|
||||||
{
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=QuickBase;Trusted_Connection=True;MultipleActiveResultSets=true");
|
||||||
|
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
public DbSet<Creditor> Creditors { get; set; }
|
public DbSet<Creditor> Creditors { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,8 @@
|
|||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\COA.EnterpriseServices.DataAccess\COA.EnterpriseServices.DataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace COA.EnterpriseServices.DataAccess.QuickBase
|
|
||||||
{
|
|
||||||
public class Class1
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace COA.EnterpriseServices.DataAccess.QuickBase
|
||||||
|
{
|
||||||
|
public class QuickBaseDataAccess<T> : IDataAccess<T> where T : class, IRecord
|
||||||
|
{
|
||||||
|
public bool Add(T item)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(T item)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollection<T> Get(int id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollection<T> Get(Expression<Func<T, bool>> query)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using System.Linq.Expressions;
|
|||||||
|
|
||||||
namespace COA.EnterpriseServices.DataAccess
|
namespace COA.EnterpriseServices.DataAccess
|
||||||
{
|
{
|
||||||
public interface IDataAccess<T> where T : IRecord
|
public interface IDataAccess<T> where T : class, IRecord
|
||||||
{
|
{
|
||||||
bool Add(T item);
|
bool Add(T item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user