Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TourDataManager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill
TourDataManager
Commits
eec4d977
Commit
eec4d977
authored
Oct 12, 2018
by
Kirill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TourPreview записываются в базу данных
parent
e1994cb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
Db.cs
TourDataManager/Db.cs
+9
-2
TourDataManager.cs
TourDataManager/TourDataManager.cs
+1
-0
No files found.
TourDataManager/Db.cs
View file @
eec4d977
...
@@ -39,6 +39,8 @@ namespace TourDataManager {
...
@@ -39,6 +39,8 @@ namespace TourDataManager {
// Эта штука отключает самостоятельную генерацию Id и позволяет мне самому устанавливать Id
// Эта штука отключает самостоятельную генерацию Id и позволяет мне самому устанавливать Id
modelBuilder
.
Entity
<
Estate
>().
Property
(
estate
=>
estate
.
Id
)
modelBuilder
.
Entity
<
Estate
>().
Property
(
estate
=>
estate
.
Id
)
.
HasDatabaseGeneratedOption
(
DatabaseGeneratedOption
.
None
);
.
HasDatabaseGeneratedOption
(
DatabaseGeneratedOption
.
None
);
modelBuilder
.
Entity
<
Tour
>().
Property
(
tour
=>
tour
.
Id
)
.
HasDatabaseGeneratedOption
(
DatabaseGeneratedOption
.
None
);
// Ещё, вероятно, помогло бы [DatabaseGenerated(DatabaseGeneratedOption.None)]
// Ещё, вероятно, помогло бы [DatabaseGenerated(DatabaseGeneratedOption.None)]
var
sqliteConnectionInitializer
=
new
SqliteDropCreateDatabaseWhenModelChanges
<
MyDbContext
>(
modelBuilder
);
var
sqliteConnectionInitializer
=
new
SqliteDropCreateDatabaseWhenModelChanges
<
MyDbContext
>(
modelBuilder
);
...
@@ -46,6 +48,7 @@ namespace TourDataManager {
...
@@ -46,6 +48,7 @@ namespace TourDataManager {
}
}
public
DbSet
<
Estate
>
Estates
{
get
;
set
;
}
public
DbSet
<
Estate
>
Estates
{
get
;
set
;
}
public
DbSet
<
Tour
>
Tours
{
get
;
set
;
}
...
@@ -72,8 +75,12 @@ namespace TourDataManager {
...
@@ -72,8 +75,12 @@ namespace TourDataManager {
foreach
(
var
estate
in
estates
){
foreach
(
var
estate
in
estates
){
context
.
Estates
.
AddOrUpdate
(
estate
);
context
.
Estates
.
AddOrUpdate
(
estate
);
}
}
foreach
(
var
contextEstate
in
context
.
Estates
){
context
.
SaveChanges
();
Debug
.
Log
(
contextEstate
.
Id
);
}
public
void
InsertTours
(
Tour
[]
tours
){
foreach
(
var
tour
in
tours
){
context
.
Tours
.
AddOrUpdate
(
tour
);
}
}
context
.
SaveChanges
();
context
.
SaveChanges
();
...
...
TourDataManager/TourDataManager.cs
View file @
eec4d977
...
@@ -50,6 +50,7 @@ namespace TourDataManager {
...
@@ -50,6 +50,7 @@ namespace TourDataManager {
public
async
Task
<
Tour
[
]>
DownloadTourPreviews
(
long
estateId
){
public
async
Task
<
Tour
[
]>
DownloadTourPreviews
(
long
estateId
){
var
tours
=
await
tourpreviewsfetch
.
FetchTourFromServerAsync
(
estateId
);
var
tours
=
await
tourpreviewsfetch
.
FetchTourFromServerAsync
(
estateId
);
database
.
InsertTours
(
tours
);
return
tours
;
return
tours
;
}
}
}
}
...
...
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