Click here to Skip to main content
15,907,687 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: .NET 7 slower than .NET 6? Pin
Richard Deeming18-Nov-22 4:19
mveRichard Deeming18-Nov-22 4:19 
GeneralRe: .NET 7 slower than .NET 6? Pin
Kevin McFarlane23-Nov-22 4:33
Kevin McFarlane23-Nov-22 4:33 
Questionfor each loop with if else statement Pin
Walter Schmidt 20221-Nov-22 10:56
Walter Schmidt 20221-Nov-22 10:56 
AnswerRe: for each loop with if else statement Pin
jochance7-Mar-23 9:20
jochance7-Mar-23 9:20 
GeneralRe: for each loop with if else statement Pin
Walter Schmidt 20227-Mar-23 10:03
Walter Schmidt 20227-Mar-23 10:03 
QuestionWhat does the Rollback method in EF Core do? Pin
dataminers30-Oct-22 23:52
dataminers30-Oct-22 23:52 
AnswerRe: What does the Rollback method in EF Core do? Pin
Richard MacCutchan31-Oct-22 0:30
mveRichard MacCutchan31-Oct-22 0:30 
GeneralRe: What does the Rollback method in EF Core do? Pin
dataminers31-Oct-22 3:14
dataminers31-Oct-22 3:14 
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:
C#
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
        }
    }
}

GeneralRe: What does the Rollback method in EF Core do? Pin
Richard Deeming31-Oct-22 3:21
mveRichard Deeming31-Oct-22 3:21 
GeneralRe: What does the Rollback method in EF Core do? Pin
dataminers31-Oct-22 21:09
dataminers31-Oct-22 21:09 
Question.net 6.0 web api how increment request timeout? Pin
ste2224-Oct-22 23:01
ste2224-Oct-22 23:01 
AnswerRe: .net 6.0 web api how increment request timeout? Pin
Richard Deeming25-Oct-22 1:48
mveRichard Deeming25-Oct-22 1:48 
QuestionWays to migrate a Silverlight application? Pin
Member 1579410912-Oct-22 22:54
Member 1579410912-Oct-22 22:54 
AnswerRe: Ways to migrate a Silverlight application? Pin
Richard Deeming12-Oct-22 23:27
mveRichard Deeming12-Oct-22 23:27 
Questioncsv file sort and create a new and store the data Pin
Member 1577533021-Sep-22 20:52
Member 1577533021-Sep-22 20:52 
AnswerRe: csv file sort and create a new and store the data Pin
Richard Deeming21-Sep-22 21:31
mveRichard Deeming21-Sep-22 21:31 
QuestionPLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 5:27
dataminers9-Sep-22 5:27 
AnswerRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 5:50
mveRichard MacCutchan9-Sep-22 5:50 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers9-Sep-22 10:18
dataminers9-Sep-22 10:18 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard MacCutchan9-Sep-22 21:53
mveRichard MacCutchan9-Sep-22 21:53 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
dataminers11-Sep-22 2:01
dataminers11-Sep-22 2:01 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Dave Kreskowiak11-Sep-22 4:36
mveDave Kreskowiak11-Sep-22 4:36 
GeneralRe: PLINQ - WithDegreeOfParallelism Pin
Richard Deeming11-Sep-22 21:39
mveRichard Deeming11-Sep-22 21:39 
QuestionMultiThread on Single Core Processor (CPU) Pin
dataminers6-Sep-22 3:24
dataminers6-Sep-22 3:24 
AnswerRe: MultiThread on Single Core Processor (CPU) Pin
dan!sh 6-Sep-22 3:46
professional dan!sh 6-Sep-22 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.