skimedic / presentations Goto Github PK
View Code? Open in Web Editor NEWCopy of my public presentations
License: MIT License
Copy of my public presentations
License: MIT License
var addCommandReference = controller.AddCommand(new AddNumbersCommand());
Hi,
I'm trying to implement your transaction wrapper asynchronously, here's my code:
[Fact]
public async Task ShouldRemoveEntityByIdAsync()
{
await ExecuteAndRollbackAsync(shouldRemoveEntityByIdAsync());
async Task shouldRemoveEntityByIdAsync()
{
var contact = new Contact { Id = AppDbContext.SeedContactId };
var entity = _DbContext.Attach(contact);
entity.State = EntityState.Deleted;
var result = await _DbContext.SaveChangesAsync();
result.Should().BeGreaterThan(0);
}
}
async Task ExecuteAndRollbackAsync(Task task)
{
await using var transaction = await _DbContext.Database.BeginTransactionAsync();
try
{
await task;
}
finally
{
if (transaction != null)
await transaction.RollbackAsync();
}
}
When I run the test, the call to BeginTransactionAsync
throws the following exception:
System.InvalidOperationException : The connection is already in a transaction and cannot participate in another transaction.
StackTrace:
RelationalConnection.EnsureNoTransactions()
RelationalConnection.BeginTransactionAsync(IsolationLevel isolationLevel, CancellationToken cancellationToken)
RelationalConnection.BeginTransactionAsync(CancellationToken cancellationToken)
Test.ExecuteAndRollbackAsync(Task task) line 55
Test.ShouldRemoveEntityByIdAsync() line 38
What am I missing?
Hi, I ended up in this repo after watching https://www.youtube.com/watch?v=4kgILKQuGjk. Would be nice to have a list of videos where other presentations was, so ppl can watch more instead of searching in the web. Thanks
https://github.com/skimedic/presentations/tree/master/Patterns/BehavioralPatterns/Command/AddNumbersCommand.cs and AddTextCommand.cs
When we use two or more Command object, UnExecute method work incorrect. For example when we add text, number and text and we want to undo last change for numberCommand we remove string (which have length of added number) from global StringBuilder object
Look at this code
var text1 = "abc";
var text2 = "defgh";
var numb1 = "1234";
var controller = new Controller();
var addNumbCommandReference = controller.AddCommand(new AddNumbersCommand());
var addTextCommandReference = controller.AddCommand(new AddTextCommand());
controller.GetCommandAt(addTextCommandReference).Execute(text1);
controller.GetCommandAt(addNumbCommandReference).Execute(numb1);
controller.GetCommandAt(addTextCommandReference).Execute(text2);
controller.GetCommandAt(addNumbCommandReference).UnExecute();
//Output
//abc1234d
//Expected:
//abcdefgh
Hi,
There is a comment in code that double lock 'is fixed in C# 6'. Could anyone please elaborate on what is meant by that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.