Created
July 1, 2018 06:56
-
-
Save danielplawgo/8529d902aa0c05d0d3ae18f1d30e5148 to your computer and use it in GitHub Desktop.
Entity Framework - aktualizacja danych bez ich pobierania
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-06-30 07:44:29.6430 INFO Opened connection at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.6669 INFO SELECT TOP (1) | |
[Extent1].[Id] AS [Id], | |
[Extent1].[Name] AS [Name], | |
[Extent1].[LockTime] AS [LockTime], | |
[Extent1].[Count] AS [Count] | |
FROM [dbo].[Products] AS [Extent1] | |
WHERE [Extent1].[Id] = @p__linq__0 | |
2018-06-30 07:44:29.6669 INFO | |
2018-06-30 07:44:29.6800 INFO -- p__linq__0: '2' (Type = Int32, IsNullable = false) | |
2018-06-30 07:44:29.6800 INFO -- Executing at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.7181 INFO -- Completed in 1 ms with result: SqlDataReader | |
2018-06-30 07:44:29.7181 INFO | |
2018-06-30 07:44:29.7340 INFO Closed connection at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.7811 INFO Opened connection at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.7895 INFO Started transaction at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.8758 INFO UPDATE [dbo].[Products] | |
SET [LockTime] = @0 | |
WHERE ([Id] = @1) | |
2018-06-30 07:44:29.8830 INFO -- @0: '30.06.2018 05:44:29' (Type = DateTime2) | |
2018-06-30 07:44:29.8830 INFO -- @1: '2' (Type = Int32) | |
2018-06-30 07:44:29.9011 INFO -- Executing at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.9198 INFO -- Completed in 11 ms with result: 1 | |
2018-06-30 07:44:29.9198 INFO | |
2018-06-30 07:44:29.9408 INFO Committed transaction at 30.06.2018 07:44:29 +02:00 | |
2018-06-30 07:44:29.9490 INFO Closed connection at 30.06.2018 07:44:29 +02:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-06-30 07:58:28.9270 INFO Opened connection at 30.06.2018 07:58:28 +02:00 | |
2018-06-30 07:58:28.9345 INFO Started transaction at 30.06.2018 07:58:28 +02:00 | |
2018-06-30 07:58:28.9345 INFO UPDATE [dbo].[Products] | |
SET [LockTime] = @0 | |
WHERE ([Id] = @1) | |
2018-06-30 07:58:28.9485 INFO -- @0: '30.06.2018 05:58:28' (Type = DateTime2) | |
2018-06-30 07:58:28.9485 INFO -- @1: '2' (Type = Int32) | |
2018-06-30 07:58:28.9607 INFO -- Executing at 30.06.2018 07:58:28 +02:00 | |
2018-06-30 07:58:28.9607 INFO -- Completed in 0 ms with result: 1 | |
2018-06-30 07:58:28.9607 INFO | |
2018-06-30 07:58:28.9876 INFO Committed transaction at 30.06.2018 07:58:28 +02:00 | |
2018-06-30 07:58:28.9946 INFO Closed connection at 30.06.2018 07:58:28 +02:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-06-30 08:11:06.8940 INFO Opened connection at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:06.8999 INFO Started transaction at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:06.8999 INFO UPDATE [dbo].[Products] | |
SET [LockTime] = @0, [Count] = @1 | |
WHERE ([Id] = @2) | |
2018-06-30 08:11:06.9149 INFO -- @0: '30.06.2018 06:11:06' (Type = DateTime2) | |
2018-06-30 08:11:06.9149 INFO -- @1: '0' (Type = Int32) | |
2018-06-30 08:11:06.9310 INFO -- @2: '2' (Type = Int32) | |
2018-06-30 08:11:06.9310 INFO -- Executing at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:06.9469 INFO -- Completed in 2 ms with result: 1 | |
2018-06-30 08:11:06.9469 INFO | |
2018-06-30 08:11:06.9651 INFO Committed transaction at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:06.9651 INFO Closed connection at 30.06.2018 08:11:06 +02:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2018-06-30 08:11:06.9930 INFO Opened connection at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:06.9930 INFO Started transaction at 30.06.2018 08:11:06 +02:00 | |
2018-06-30 08:11:07.0100 INFO DELETE [dbo].[Products] | |
WHERE ([Id] = @0) | |
2018-06-30 08:11:07.0100 INFO | |
2018-06-30 08:11:07.0100 INFO -- @0: '4' (Type = Int32) | |
2018-06-30 08:11:07.0260 INFO -- Executing at 30.06.2018 08:11:07 +02:00 | |
2018-06-30 08:11:07.0260 INFO -- Completed in 1 ms with result: 1 | |
2018-06-30 08:11:07.0391 INFO | |
2018-06-30 08:11:07.0391 INFO Committed transaction at 30.06.2018 08:11:07 +02:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = db.Products.FirstOrDefault(p => p.Id == productId); | |
if (product == null) | |
{ | |
return; | |
} | |
product.LockTime = DateTime.UtcNow; | |
db.SaveChanges(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = new Product() | |
{ | |
Id = productId | |
}; | |
db.Set<Product>().Attach(product); | |
product.LockTime = DateTime.UtcNow; | |
product.Count = 0; | |
db.SaveChanges(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = new Product() | |
{ | |
Id = productId | |
}; | |
db.Set<Product>().Attach(product); | |
product.LockTime = DateTime.UtcNow; | |
product.Count = 0; | |
db.Entry(product).Property(p => p.Count).IsModified = true; | |
db.SaveChanges(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = new Product() | |
{ | |
Id = productId | |
}; | |
db.Entry(product).State = EntityState.Deleted; | |
db.SaveChanges(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment