mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2024-11-09 23:44:20 +01:00
Reworking DbAccess
This commit is contained in:
parent
e0352e374c
commit
ce90818e3d
|
@ -130,6 +130,7 @@ namespace SharpRss
|
||||||
}
|
}
|
||||||
public static async Task<FeedModel?> SetFeedsAsync(IEnumerable<FeedModel> feedModels)
|
public static async Task<FeedModel?> SetFeedsAsync(IEnumerable<FeedModel> feedModels)
|
||||||
{
|
{
|
||||||
|
//TODO: Implement fetching system!!!
|
||||||
FeedModel? resultModel = null;
|
FeedModel? resultModel = null;
|
||||||
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
await using SqliteConnection dbc = new SqliteConnection(ConnectionString);
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
|
@ -153,7 +154,8 @@ namespace SharpRss
|
||||||
new SqliteParameter("lastUpdated", feedModel.LastUpdated?.ToUnixTimeMilliseconds()),
|
new SqliteParameter("lastUpdated", feedModel.LastUpdated?.ToUnixTimeMilliseconds()),
|
||||||
new SqliteParameter("imageUrl", feedModel.ImageUrl ?? string.Empty),
|
new SqliteParameter("imageUrl", feedModel.ImageUrl ?? string.Empty),
|
||||||
new SqliteParameter("originalDoc", feedModel.OriginalDocument ?? string.Empty)
|
new SqliteParameter("originalDoc", feedModel.OriginalDocument ?? string.Empty)
|
||||||
}
|
},
|
||||||
|
Transaction = transaction
|
||||||
};
|
};
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
@ -225,7 +227,10 @@ namespace SharpRss
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
await using SqliteTransaction transaction = dbc.BeginTransaction();
|
await using SqliteTransaction transaction = dbc.BeginTransaction();
|
||||||
await using SqliteCommand cmd = new SqliteCommand($"INSERT OR REPLACE INTO {FeedItemTable} (id, feed_id, read, title, description, link, last_updated, publishing_date, author, categories, content)" +
|
await using SqliteCommand cmd = new SqliteCommand($"INSERT OR REPLACE INTO {FeedItemTable} (id, feed_id, read, title, description, link, last_updated, publishing_date, author, categories, content)" +
|
||||||
$"VALUES (IFNULL((SELECT id FROM {FeedItemTable} WHERE link=@link), @id), @feedId, @read, @title, @description, @link, @lastUpdated, @publishingDate, @author, @categories, @content)", dbc);
|
$"VALUES (IFNULL((SELECT id FROM {FeedItemTable} WHERE link=@link), @id), @feedId, @read, @title, @description, @link, @lastUpdated, @publishingDate, @author, @categories, @content)", dbc)
|
||||||
|
{
|
||||||
|
Transaction = transaction
|
||||||
|
};
|
||||||
foreach (FeedItemModel item in items)
|
foreach (FeedItemModel item in items)
|
||||||
{
|
{
|
||||||
cmd.Parameters.Clear();
|
cmd.Parameters.Clear();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user