public void InsertLink(LinkTag t) { var database = Client.GetDatabase("webdb"); var collection = database.GetCollection<BsonDocument>("links"); collection.InsertOne(new BsonDocument { {"LinkId", Guid.NewGuid() }, {"PageId", t.PageId.ToString() }, {"Tag", t.Tag }, {"Path", t.Url.GetFullPath(false) }, {"AggregatedDateTime", DateTime.Now } }); }
public void InsertLink(LinkTag t) { var database = Client.GetDatabase("webdb"); var collection = database.GetCollection <BsonDocument>("links"); collection.InsertOne(new BsonDocument { { "LinkId", Guid.NewGuid() }, { "PageId", t.PageId.ToString() }, { "Tag", t.Tag }, { "Path", t.Url.GetFullPath(false) }, { "AggregatedDateTime", DateTime.Now } }); }
public void InsertLink(LinkTag t) { string sql = "INSERT INTO LinkTable (LinkId, PageId, Tag, Path) VALUES (@LinkId, @PageId, @Tag, @Path);"; try { using (MySqlCommand c = new MySqlCommand(sql, client)) { c.Parameters.AddWithValue("@LinkId", Guid.NewGuid()); c.Parameters.AddWithValue("@PageId", t.PageId.ToString()); c.Parameters.AddWithValue("@Tag", t.Tag); c.Parameters.AddWithValue("@Path", t.Url.GetFullPath(false)); c.ExecuteNonQuery(); } Console.WriteLine("Link persisted: " + t.Url.GetFullPath(false)); } catch (Exception e) { log.Error("Inserting link failed", e); // throw; } }