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
6 years ago
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 {
// Эта штука отключает самостоятельную генерацию Id и позволяет мне самому устанавливать Id
modelBuilder
.
Entity
<
Estate
>().
Property
(
estate
=>
estate
.
Id
)
.
HasDatabaseGeneratedOption
(
DatabaseGeneratedOption
.
None
);
modelBuilder
.
Entity
<
Tour
>().
Property
(
tour
=>
tour
.
Id
)
.
HasDatabaseGeneratedOption
(
DatabaseGeneratedOption
.
None
);
// Ещё, вероятно, помогло бы [DatabaseGenerated(DatabaseGeneratedOption.None)]
var
sqliteConnectionInitializer
=
new
SqliteDropCreateDatabaseWhenModelChanges
<
MyDbContext
>(
modelBuilder
);
...
...
@@ -46,6 +48,7 @@ namespace TourDataManager {
}
public
DbSet
<
Estate
>
Estates
{
get
;
set
;
}
public
DbSet
<
Tour
>
Tours
{
get
;
set
;
}
...
...
@@ -72,8 +75,12 @@ namespace TourDataManager {
foreach
(
var
estate
in
estates
){
context
.
Estates
.
AddOrUpdate
(
estate
);
}
foreach
(
var
contextEstate
in
context
.
Estates
){
Debug
.
Log
(
contextEstate
.
Id
);
context
.
SaveChanges
();
}
public
void
InsertTours
(
Tour
[]
tours
){
foreach
(
var
tour
in
tours
){
context
.
Tours
.
AddOrUpdate
(
tour
);
}
context
.
SaveChanges
();
...
...
This diff is collapsed.
Click to expand it.
TourDataManager/TourDataManager.cs
View file @
eec4d977
...
...
@@ -50,6 +50,7 @@ namespace TourDataManager {
public
async
Task
<
Tour
[
]>
DownloadTourPreviews
(
long
estateId
){
var
tours
=
await
tourpreviewsfetch
.
FetchTourFromServerAsync
(
estateId
);
database
.
InsertTours
(
tours
);
return
tours
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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