Example #1
0
        public static bool DbInsert(this TNode entity, SQLiteConnection connection)
        {
            var command = connection.CreateCommand();
            Dictionary <string, string> NameValues = new Dictionary <string, string>();

            NameValues.Add(nameof(entity.IssueType), SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType));
            NameValues.Add(nameof(entity.IssueDateTime), SQLiteHelper.ToSQLiteString(entity.IssueDateTime));
            NameValues.Add(nameof(entity.NodeCode), SQLiteHelper.ToSQLiteString(entity.NodeCode));
            NameValues.Add(nameof(entity.Data), SQLiteHelper.ToSQLiteString(entity.Data));
            NameValues.Add(nameof(entity.ElementIds), SQLiteHelper.ToSQLiteString(entity.GetElementIds()));
            NameValues.Add(SQLiteHelper.ToSQLiteReservedField(nameof(entity.Index)), SQLiteHelper.ToSQLiteString(entity.Index));
            command.CommandText = SQLiteHelper.GetSQLiteQuery_Insert(entity.TableName, NameValues);
            return(command.ExecuteNonQuery() == 1);
        }
Example #2
0
        public static bool DbUpdate(this TNode entity, SQLiteConnection connection)
        {
            var command = connection.CreateCommand();
            Dictionary <string, string> sets = new Dictionary <string, string>();

            sets.Add(nameof(entity.Data), SQLiteHelper.ToSQLiteString(entity.Data));
            sets.Add(nameof(entity.ElementIds), SQLiteHelper.ToSQLiteString(entity.GetElementIds()));
            sets.Add(SQLiteHelper.ToSQLiteReservedField(nameof(entity.Index)), SQLiteHelper.ToSQLiteString(entity.Index));
            List <KeyOperatorValue> wheres = new List <KeyOperatorValue>();

            wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime)));
            wheres.Add(new KeyOperatorValue(nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType)));
            wheres.Add(new KeyOperatorValue(nameof(entity.NodeCode), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.NodeCode)));
            command.CommandText = SQLiteHelper.GetSQLiteQuery_Update(entity.TableName, sets, wheres);
            return(command.ExecuteNonQuery() == 1);
        }