Skip to content

Commit 0404fe3

Browse files
committed
Added EntityFrameworkCore project.
1 parent 621618f commit 0404fe3

File tree

15 files changed

+156
-23
lines changed

15 files changed

+156
-23
lines changed

AbpCompanyName.AbpProjectName.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpCompanyName.AbpProjectNa
1616
EndProject
1717
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpCompanyName.AbpProjectName.Application", "src\AbpCompanyName.AbpProjectName.Application\AbpCompanyName.AbpProjectName.Application.xproj", "{3870C648-4AEA-4B85-BA3F-F2F63B96136A}"
1818
EndProject
19+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpCompanyName.AbpProjectName.EntityFrameworkCore", "src\AbpCompanyName.AbpProjectName.EntityFrameworkCore\AbpCompanyName.AbpProjectName.EntityFrameworkCore.xproj", "{DC780BC4-4EAC-4C63-9052-6F3169A59FA4}"
20+
EndProject
1921
Global
2022
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2123
Debug|Any CPU = Debug|Any CPU
@@ -34,6 +36,10 @@ Global
3436
{3870C648-4AEA-4B85-BA3F-F2F63B96136A}.Debug|Any CPU.Build.0 = Debug|Any CPU
3537
{3870C648-4AEA-4B85-BA3F-F2F63B96136A}.Release|Any CPU.ActiveCfg = Release|Any CPU
3638
{3870C648-4AEA-4B85-BA3F-F2F63B96136A}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4}.Release|Any CPU.Build.0 = Release|Any CPU
3743
EndGlobalSection
3844
GlobalSection(SolutionProperties) = preSolution
3945
HideSolutionNode = FALSE
@@ -42,5 +48,6 @@ Global
4248
{A2213374-BB48-48FD-BBD4-81E6A961D866} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
4349
{0FA75A5B-AB83-4FD0-B545-279774C01E87} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
4450
{3870C648-4AEA-4B85-BA3F-F2F63B96136A} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
51+
{DC780BC4-4EAC-4C63-9052-6F3169A59FA4} = {AFAA0841-BD93-466F-B8F4-FB4EEC86F1FC}
4552
EndGlobalSection
4653
EndGlobal

src/AbpCompanyName.AbpProjectName.Application/AbpProjectNameAppServiceBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Abp.Application.Services;
2+
using Abp.ObjectMapping;
23

34
namespace AbpCompanyName.AbpProjectName
45
{
@@ -7,8 +8,15 @@ namespace AbpCompanyName.AbpProjectName
78
/// </summary>
89
public abstract class AbpProjectNameAppServiceBase : ApplicationService
910
{
11+
/// <summary>
12+
/// Reference to the object to object mapper.
13+
/// TODO: REMOVE THIS WHEN IT'S ADDED TO ApplicationService in Abp.
14+
/// </summary>
15+
public IObjectMapper ObjectMapper { get; set; }
16+
1017
protected AbpProjectNameAppServiceBase()
1118
{
19+
ObjectMapper = NullObjectMapper.Instance;
1220
LocalizationSourceName = AbpProjectNameConsts.LocalizationSourceName;
1321
}
1422
}

src/AbpCompanyName.AbpProjectName.Application/AbpProjectNameApplicationModule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System.Reflection;
2+
using Abp.AutoMapper;
23
using Abp.Modules;
34

45
namespace AbpCompanyName.AbpProjectName
56
{
6-
[DependsOn(typeof(AbpProjectNameCoreModule))]
7+
[DependsOn(typeof(AbpProjectNameCoreModule), typeof(AbpAutoMapperModule))]
78
public class AbpProjectNameApplicationModule : AbpModule
89
{
910
public override void Initialize()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using Abp.Application.Services.Dto;
2+
using Abp.AutoMapper;
23

34
namespace AbpCompanyName.AbpProjectName.Products.Dtos
45
{
6+
[AutoMapFrom(typeof(Product))]
57
public class ProductDto : EntityDto
68
{
79
public string Name { get; set; }
810

9-
public float Price { get; set; }
11+
public float? Price { get; set; }
1012
}
1113
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using Abp.Application.Services;
1+
using System.Threading.Tasks;
2+
using Abp.Application.Services;
23
using Abp.Application.Services.Dto;
34
using AbpCompanyName.AbpProjectName.Products.Dtos;
45

56
namespace AbpCompanyName.AbpProjectName.Products
67
{
78
public interface IProductAppService : IApplicationService
89
{
9-
ListResultOutput<ProductDto> GetAllProducts();
10+
Task<ListResultOutput<ProductDto>> GetAllProducts();
1011
}
1112
}
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
using Abp.Application.Services.Dto;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Abp.Application.Services.Dto;
4+
using Abp.Domain.Repositories;
25
using AbpCompanyName.AbpProjectName.Products.Dtos;
36

47
namespace AbpCompanyName.AbpProjectName.Products
58
{
69
public class ProductAppService : AbpProjectNameAppServiceBase, IProductAppService
710
{
8-
public ListResultOutput<ProductDto> GetAllProducts()
11+
private readonly IRepository<Product> _productRepository;
12+
13+
public ProductAppService(IRepository<Product> productRepository)
14+
{
15+
_productRepository = productRepository;
16+
}
17+
18+
public async Task<ListResultOutput<ProductDto>> GetAllProducts()
919
{
10-
return new ListResultOutput<ProductDto>(new []
11-
{
12-
new ProductDto
13-
{
14-
Name = "Acme 23 inch monitor.",
15-
Price = 899.9f
16-
},
17-
new ProductDto
18-
{
19-
Name = "Acme wireless keyboard and mouse set.",
20-
Price = 95.0f
21-
}
22-
});
20+
var products = await _productRepository.GetAllListAsync();
21+
return new ListResultOutput<ProductDto>(
22+
ObjectMapper.Map<List<ProductDto>>(products)
23+
);
2324
}
2425
}
2526
}

src/AbpCompanyName.AbpProjectName.Application/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "1.0.0.0-*",
33

44
"dependencies": {
5+
"Abp.AutoMapper": "0.9.4",
56
"AbpCompanyName.AbpProjectName.Core": "1.0.0.0-*"
67
},
78

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using Abp.Domain.Entities.Auditing;
3+
4+
namespace AbpCompanyName.AbpProjectName.Products
5+
{
6+
public class Product : AuditedEntity
7+
{
8+
public const int MaxNameLength = 128;
9+
10+
[Required]
11+
[StringLength(MaxNameLength)]
12+
public string Name { get; set; }
13+
14+
public float? Price { get; set; }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>dc780bc4-4eac-4c63-9052-6f3169a59fa4</ProjectGuid>
10+
<RootNamespace>AbpCompanyName.AbpProjectName</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14+
</PropertyGroup>
15+
<PropertyGroup>
16+
<SchemaVersion>2.0</SchemaVersion>
17+
</PropertyGroup>
18+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
19+
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Abp.EntityFrameworkCore;
2+
using AbpCompanyName.AbpProjectName.Products;
3+
using Microsoft.EntityFrameworkCore;
4+
5+
namespace AbpCompanyName.AbpProjectName.EntityFrameworkCore
6+
{
7+
public class AbpProjectNameDbContext : AbpDbContext
8+
{
9+
//TODO: Define an DbSet for each Entity...
10+
11+
public DbSet<Product> Products { get; set; }
12+
13+
public AbpProjectNameDbContext(DbContextOptions<AbpProjectNameDbContext> options)
14+
: base(options)
15+
{
16+
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)