Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
丁松杰
/
Pole
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c771ea77
authored
Feb 17, 2020
by
丁松杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 orleans entityframework 集成测试
parent
be19a9e3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
3 deletions
samples/apis/Product.Api/Controllers/ProductTypeController.cs
samples/apis/Product.Api/Grains/ProductTypeGrain.cs
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductTypeEntityConfiguration.cs
src/Pole.Core/Domain/Entity.cs
src/Pole.Core/Grains/PoleGrain.cs
src/Pole.Orleans.Provider.EntityframeworkCore/Conventions/GrainStorageConventionOptions.cs
samples/apis/Product.Api/Controllers/ProductTypeController.cs
View file @
c771ea77
...
...
@@ -21,7 +21,7 @@ namespace Product.Api.Controllers
[
HttpGet
(
"AddProductType"
)]
public
void
AddProductType
(
string
name
=
"test"
)
{
var
newId
=
Guid
.
NewGuid
().
ToString
(
"N"
).
ToLower
()
;
var
newId
=
"da8a489fa7b4409294ee1b358fbbfba5"
;
var
grain
=
clusterClient
.
GetGrain
<
IProductTypeGrain
>(
newId
);
grain
.
AddProductType
(
newId
,
name
);
}
...
...
samples/apis/Product.Api/Grains/ProductTypeGrain.cs
View file @
c771ea77
using
Orleans
;
using
Pole.Core.Grains
;
using
Product.Api.Domain.AggregatesModel.ProductTypeAggregate
;
using
Product.Api.Grains.Abstraction
;
using
System
;
...
...
@@ -8,7 +9,7 @@ using System.Threading.Tasks;
namespace
Product.Api.Grains
{
public
class
ProductType
Grain
:
Grain
<
ProductType
>,
IProductTypeGrain
public
class
ProductType
PoleGrainGrain
:
Pole
Grain
<
ProductType
>,
IProductTypeGrain
{
public
async
Task
<
bool
>
AddProductType
(
string
id
,
string
name
)
{
...
...
@@ -20,6 +21,7 @@ namespace Product.Api.Grains
Name
=
name
};
State
=
productType
;
Add
(
productType
);
await
WriteStateAsync
();
return
true
;
}
...
...
samples/apis/Product.Api/Infrastructure/EntityConfigurations/ProductTypeEntityConfiguration.cs
View file @
c771ea77
...
...
@@ -18,6 +18,7 @@ namespace Product.Api.Infrastructure.EntityConfigurations
builder
.
Property
(
m
=>
m
.
Name
).
HasMaxLength
(
256
).
IsRequired
();
builder
.
Ignore
(
m
=>
m
.
DomainEvents
);
builder
.
Ignore
(
m
=>
m
.
IsPersisted
);
builder
.
HasKey
(
m
=>
m
.
Id
);
}
...
...
src/Pole.Core/Domain/Entity.cs
View file @
c771ea77
...
...
@@ -20,6 +20,8 @@ namespace Pole.Core.Domain
}
}
public
List
<
IEvent
>
DomainEvents
{
get
;
private
set
;
}
public
bool
IsPersisted
{
get
;
set
;
}
public
bool
IsTransient
()
{
return
string
.
IsNullOrEmpty
(
this
.
_id
);
...
...
src/Pole.Core/Grains/PoleGrain.cs
0 → 100644
View file @
c771ea77
using
Orleans
;
using
Pole.Core.Domain
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Pole.Core.Grains
{
public
abstract
class
PoleGrain
<
TAggregateRoot
>
:
Grain
<
TAggregateRoot
>,
IGrainWithStringKey
where
TAggregateRoot
:
Entity
,
IAggregateRoot
,
new
()
{
public
void
Update
(
TAggregateRoot
aggregateRoot
)
{
aggregateRoot
.
IsPersisted
=
true
;
}
public
void
Add
(
TAggregateRoot
aggregateRoot
)
{
aggregateRoot
.
IsPersisted
=
false
;
}
}
}
src/Pole.Orleans.Provider.EntityframeworkCore/Conventions/GrainStorageConventionOptions.cs
View file @
c771ea77
...
...
@@ -10,6 +10,6 @@ namespace Pole.Orleans.Provider.EntityframeworkCore.Conventions
public
string
DefaultGrainKeyExtPropertyName
{
get
;
set
;
}
=
"KeyExt"
;
public
string
DefaultPersistenceCheckPropertyName
{
get
;
set
;
}
=
"Id"
;
public
string
DefaultPersistenceCheckPropertyName
{
get
;
set
;
}
=
"I
sPersiste
d"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment