none
The Entityframework inserts data to sqlite very slowly RRS feed

  • Question

  •   using (MyContext context = new MyContext())
                                        {
                                            SotreData Atten = new SotreData
                                            {
                                                Channel = "UD",
                                                data = Iarr[i].ToString(),
                                                dt = start
                                            };
                                            context.SotreDatas.Add(Atten);
                                            context.SaveChanges();
                                        }


    please verify my account

    • Moved by CoolDadTx Monday, May 8, 2017 1:37 PM EF related
    Monday, May 8, 2017 9:31 AM

Answers

  • I use the data graph, and

    Save the raw data


    please verify my account

    Still see no issues. The code supplied is fine so unless you have something else to add my response is the same, I see no issues.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by lctk Saturday, May 27, 2017 12:13 AM
    Monday, May 8, 2017 10:50 AM
  • I would try a different approach by using AddRange works off a list.

    using(MyContext context = new MyContext()) {
     var sotreDatas = new List<SotreData>();
    
     for (int i = 0; i < Iarr2.Length; i++) {
      SotreData Atten = new SotreData {
       Channel = "UD",
        data = Iarr[i].ToString(),
        dt = start
      };
    
      list.Add(Atten);
     }
    
     context.SotreDatas.AddRange(sotreDatas);
     context.SaveChanges();
    }



    william xifaras


    • Edited by William Xifaras Monday, May 8, 2017 3:15 PM
    • Marked as answer by lctk Saturday, May 27, 2017 12:13 AM
    Monday, May 8, 2017 3:07 PM

All replies

  • You really need to supply much more in details as what is shown looks fine.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, May 8, 2017 10:09 AM
  •    for (int i = 0; i < Iarr2.Length; i++)
                            {
                                using (MyContext context = new MyContext())
                                {
                                    SotreData Atten = new SotreData
                                    {
                                        Channel = "UD",
                                        data = Iarr[i].ToString(),
                                        dt = start
                                    };
                                    context.SotreDatas.Add(Atten);
                                    context.SaveChanges();
                                }

    The above code, insert data into the sqlite database, is very slow,

    I use the winform program to draw dynamic graphics on top of the form because the code above becomes very caton


    please verify my account

    Monday, May 8, 2017 10:15 AM
  • But I write to the TXT file very quickly

    please verify my account

    Monday, May 8, 2017 10:16 AM

  • The above code, insert data into the sqlite database, is very slow,

    I use the winform program to draw dynamic graphics on top of the form because the code above becomes very caton


    please verify my account

    Yes you have already indicated the operation is slow, what does graphics have to do with saving data?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, May 8, 2017 10:30 AM
  • But I write to the TXT file very quickly

    please verify my account

    Then why use Entity Framework as this will be slower then writing to a text file.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, May 8, 2017 10:31 AM
  • Ef writes data to sqlite database VS

     c#  Writing data to TXT is very slow


    please verify my account


    • Edited by lctk Monday, May 8, 2017 10:36 AM
    Monday, May 8, 2017 10:36 AM
  • I use the data graph, and

    Save the raw data


    please verify my account

    Monday, May 8, 2017 10:37 AM
  • I use the data graph, and

    Save the raw data


    please verify my account

    Still see no issues. The code supplied is fine so unless you have something else to add my response is the same, I see no issues.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by lctk Saturday, May 27, 2017 12:13 AM
    Monday, May 8, 2017 10:50 AM
  • I would try a different approach by using AddRange works off a list.

    using(MyContext context = new MyContext()) {
     var sotreDatas = new List<SotreData>();
    
     for (int i = 0; i < Iarr2.Length; i++) {
      SotreData Atten = new SotreData {
       Channel = "UD",
        data = Iarr[i].ToString(),
        dt = start
      };
    
      list.Add(Atten);
     }
    
     context.SotreDatas.AddRange(sotreDatas);
     context.SaveChanges();
    }



    william xifaras


    • Edited by William Xifaras Monday, May 8, 2017 3:15 PM
    • Marked as answer by lctk Saturday, May 27, 2017 12:13 AM
    Monday, May 8, 2017 3:07 PM