Thank you for the explanation. Actually, I guessed but wasn't sure. Many thanks @RichardDeeming @Richard-MacCutchan
dataminers
Posts
-
What does the Rollback method in EF Core do? -
What does the Rollback method in EF Core do?Thanks for the answer @Richard-MacCutchan I read the article, but I didn't get the exact answer to my question. The EF Core working structure is different. Each process is primarily tracked on the memory. Makes my question a little clearer. What is the difference in effect between the two codes below? FIRST CODE:
using (var context = new AppDbContext())
{
using (var transaction = context.Database.BeginTransaction())
{
try
{
var myObjectOne = new MyObjectOne() { Name = "Book" };
context.MyObjectOnes.Add(myObjectOne);
context.SaveChanges();var myVal = myObjectOne.Id \* 3.14; //Suppose an error occurs here var myObjectTwo = new MyObjectTwo() { Name = "Notebook", Price = 100, ReferenceId = myVal }; context.MyObjectTwos.Add(myObjectTwo); context.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } }
}
SECOND CODE:
using (var context = new AppDbContext())
{
using (var transaction = context.Database.BeginTransaction())
{
try
{
var myObjectOne = new MyObjectOne() { Name = "Book" };
context.MyObjectOnes.Add(myObjectOne);
context.SaveChanges();var myVal = myObjectOne.Id \* 3.14; //Suppose an error occurs here var myObjectTwo = new MyObjectTwo() { Name = "Notebook", Price = 100, ReferenceId = myVal }; context.MyObjectTwos.Add(myObjectTwo); context.SaveChanges(); transaction.Commit(); } catch (Exception ex) { //Nothing } }
}
-
What does the Rollback method in EF Core do?Hi, RollBack method; Roll back whatever changes have been made to the database. Following example I didn't use Commit(), what will RollBack() do? What exactly did transaction.Rollback() do?
using (var context = new AppDbContext())
{
using (var transaction = context.Database.BeginTransaction())
{
try
{
var myObjectOne = new MyObjectOne() { Name = "Book" };
context.MyObjectOnes.Add(myObjectOne);
context.SaveChanges();var myVal = myObjectOne.Id \* 3.14; //Suppose an error occurs here var myObjectTwo = new MyObjectTwo() { Name = "Notebook", Price = 100, ReferenceId = myVal }; context.MyObjectTwos.Add(myObjectTwo); context.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } }
}
thanks... :confused:
-
Async - awaitThank you very much for your interest and concern @RichardDeeming
-
Async - awaitI got my answer, thanks. I have one more question. You said "it blocks the rest of the method" yes the following codes will not be executed until the job is complete, what exactly is waiting here? I guess it was a deep question :^)
-
Async - awaitHi, Why Sample #2 is "Bets Practices". Second sample include "await" keyword on the same line with Async Method. Both codes are blocking Thread. Any idea? thanks... Sample #1
var products = _context.Products.ToList();
Sample #2
var products = await _context.Products.ToListAsync();
-
PLINQ - WithDegreeOfParallelismSometimes people get confused when you read a lot. You know, not all information on the Internet is correct. That's why I'm investigating the issue. Please don't get me wrong. Multi-Thread: Running more than one Threads inside a Process. Parallel Programming: Running threads simultaneously on different cores in multi-core processors. So; .NET Core TPL (Task Parallel Library) is Multi-Thread programming, not a Parallel Programming. Isn't it?
-
PLINQ - WithDegreeOfParallelismDear Richard, thank you for your reply. I understand that based on your answer, the two code blocks below are the same;
await Task.Run(() =>
{
CalculateSomething(5);
});await Task.Run(() =>
{
CalculateSomething(8);
});List myList = new() { 5, 8 };
myList.AsParallel().WithDegreeOfParallelism(2).ForAll(x =>
{
CalculateSomething(x);
});Both complete the process on two Threads. Note: CalculateSomething hypothetically this function takes a very long time Regards...
-
PLINQ - WithDegreeOfParallelismWithDegreeOfParallelism: Degree of parallelism is the maximum number of concurrently executing tasks that will be used to process the query. I don't quite understand what you mean by this sentence. --> "concurrently executing tasks" What exactly is meant by "TASK"? CPU or Kernel or something else??? What does "3" do in the code block below; AdventureWorks2017Context context = new AdventureWorks2017Context(); context.Products.AsParallel().WithDegreeOfParallelism(3).ForAll(p => { //ToDO }) Best Regards...
-
MultiThread on Single Core Processor (CPU)many thanks...
-
MultiThread on Single Core Processor (CPU)Is it possible to run multi-threads on a single-core processor? Best Regards...
-
Catch JavaScript errorsIs it enough methods for capture and report JavaScript errors on web page on computer and mobile devices?
window.onerror = function (msg, url, lineNo, columnNo, error) {
//post data for log
return true;
}; -
Capture and report JavaScript errorsIs it enough for methods to be capture and report JavaScript errors on web applications on computer and mobile devices?
window.onerror = function (msg, url, lineNo, columnNo, error) {
//post data for log
return true;
}; -
vector based 2D line drawingThanks for reply, bu i dont want to render image, i just; want to draw line from x-y point to x-y point GDI+ Sample; Pen myPen = new Pen(Color.Blue, 2); Point myStartPoint = new Point(10, 10); Point myEndPoint = new Point(15, 5); myGraphics.DrawLine(myPen, myStartPoint, myEndPoint); But its created pixel by pixel. Real example; If I use MS Paint and i draw cross line, line will be shown pixel by pixel If I use Inkscape (its vector graphics software) and i draw cross line, line will be shown smooth. thanks...
-
vector based 2D line drawingActually I want to draw cross line use with X - Y coordinates and save as PDF format. For example; FROM New Point(x: 10, y: 10) TO New Point(x: 15, y: 5) AND DRAW LINE. If I use GDI+ library, this line shown pixel. I want to smooth line. MS Paint Pixel based drawing program, If I draw cross line on MS Paint, will be shown pixel. If I use Inkscape (its vector graphics software) and draw cross line after save as PDF file so line will be smooth.
-
vector based 2D line drawingActually I want to draw cross line use with X - Y coordinates and save as PDF format. For example FROM New Point(x: 10, y: 10) TO New Point(x: 15, y: 5) AND DRAW LINE. If I use GDI+ library, this line shown pixel. I want to smooth line. MS Paint Pixel based drawing program, If I draw cross line on MS Paint, will be shown pixel. If I use Inkscape (its vector graphics software) and draw cross line after save as PDF file so line will be smooth.
-
vector based 2D line drawingHi, How can i vector based 2D line drawing in C#. I want to get smooth line when i get printout, so i don't want to pixel based drawing. Whats is the easiest way? many thanks...
-
How can I detect a VPN connectionThere is any way for detecting client request is from Virtual Private Network or directly client computer?
-
How can I detect a VPN connectionHow can I detect a VPN connection? How can I detecting application request from VPN, Is it possible?
-
MVC Config File / MAPPINGThis night I try the asp.net mvc framework which is ASP.NET MVC 2 Empty Web Application. I create controller class, model class and view page. Its successfully run. But I can't find configuration file for classes and page mapping. Actually I want to mapping classes and views by custom on xml based file like spring bean xml configuration on Java environment. thanks your advice...