当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteConnection.InsertAll方法代码示例

本文整理汇总了C#中SQLiteConnection.InsertAll方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.InsertAll方法的具体用法?C# SQLiteConnection.InsertAll怎么用?C# SQLiteConnection.InsertAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLiteConnection的用法示例。


在下文中一共展示了SQLiteConnection.InsertAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: parseButton_Click

        private void parseButton_Click(object sender, EventArgs e)
        {
            String[] text = File.ReadAllLines(filePath);

            Parser parser = new Parser(text);

            spells = parser.getAllSpells();

            String[] classSpellsLines = File.ReadAllLines(@"../../classes.txt");
            ClassParser classParser = new ClassParser(classSpellsLines, spells);
            List<Class> cs = classParser.getAllClasses();

            File.Delete(@"d:\dnd\dndspells.sqlite");
            SQLiteConnection db = new SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), @"d:\dnd\dndspells.sqlite");

            List<ClassToSpell> cts = new List<ClassToSpell>();

            db.CreateTable<Spell>();
            db.InsertAll(spells);

            db.CreateTable<Class>();
            db.InsertAll(cs);

            foreach (var classSpell in cs)
            {
                foreach (var spell in classSpell.Spells)
                {
                    cts.Add(new ClassToSpell() { ClassSpellId = (int)classSpell.ClassType, SpellId = spell.Id });
                }
            }

            db.CreateTable<ClassToSpell>();
            db.InsertAll(cts);

            populateList();
        }
开发者ID:mostak,项目名称:dnd,代码行数:36,代码来源:Form1.cs

示例2: AddAllGradesToStudent

 public static void AddAllGradesToStudent(IEnumerable<Grade> list, int studentId)
 {
     using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
     {
         var grades = new List<Grade>();
         foreach (var item in list)
         {
             item.StudentId = studentId;
             grades.Add(item);
         }
         db.InsertAll(grades);
     }
 }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:13,代码来源:Database.cs

示例3: AddAllStudents

 /// <summary>
 /// Add many students
 /// </summary>
 /// <param name="list"></param>
 public static void AddAllStudents(IEnumerable<Student> list)
 {
     using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
     {
         db.InsertAll(list);
     }
 }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:11,代码来源:Database.cs

示例4: Init

        public static void Init(List<LogOutputDirections> outputDirectionList)
        {
            _outputDirectionList = outputDirectionList;



            if (_outputDirectionList.Contains(LogOutputDirections.LocalFile))
            {
                Task.Run(async () =>
                {
                    while (true)
                    {
                        if (_logCache4File.Count == 0)
                        {
                            await Task.Delay(TimeSpan.FromSeconds(10));
                            continue;
                        }

                        var tmpLogList = new List<string>();

                        while (_logCache4File.Count > 0)
                        {
                            var lineLog = _logCache4File.Take();
                            tmpLogList.Add(lineLog);
                        }

                        var localFolder = ApplicationData.Current.LocalFolder;
                        var nowDateStr = DateTime.Now.ToString("yyMMdd");

                        try
                        {
                            var file = await localFolder.CreateFileAsync($"{nowDateStr}.log", CreationCollisionOption.OpenIfExists);
                            await FileIO.AppendLinesAsync(file, tmpLogList);
                        }
                        catch (Exception ex)
                        {
                            Log.e($"Log.Init file writing ... ex : \n{ex}");
                        }
                    }
                });
            }



            if (_outputDirectionList.Contains(LogOutputDirections.LocalSqliteDb))
            {
                Task.Run(async () =>
                {
                    while (true)
                    {
                        if (_logCache4Sqlite.Count == 0)
                        {
                            await Task.Delay(TimeSpan.FromSeconds(10));
                            continue;
                        }

                        var tmpLogList = new List<SqliteLogEntity>();

                        while (_logCache4Sqlite.Count > 0)
                        {
                            var log = _logCache4Sqlite.Take();
                            tmpLogList.Add(log);
                        }

                        using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), Path.Combine(ApplicationData.Current.LocalFolder.Path, "log.sqlite")))
                        {
                            var tiList = db.GetTableInfo(typeof(SqliteLogEntity).Name);

                            if (!tiList.Any())
                            {
                                db.CreateTable<SqliteLogEntity>();
                            }

                            var list = db.Table<SqliteLogEntity>().Take(10).ToList();

                            db.InsertAll(tmpLogList);
                        }
                    }
                });
            }




        }
开发者ID:HyundongHwang,项目名称:HUwpBaseLib,代码行数:85,代码来源:Log.cs


注:本文中的SQLiteConnection.InsertAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。