Пример #1
0
        public TransactionResult AddManyToManyRelation(ManyToManyRelation attribute, object sourceId, Model model)
        {
            TransactionResult result = new TransactionResult(SQLiteErrorCode.Ok, null);

            if (model != null)
            {
                var query = string.Format("INSERT INTO {0} ({1}, {2}) VALUES('{3}', '{4}')",
                                          attribute.JoinTable,
                                          attribute.JoinSourceId,
                                          attribute.JoinTargetId,
                                          sourceId,
                                          model.PrimaryKeyValue
                                          );

                result = this.WriteQuery(query);
            }

            return(result);
        }
Пример #2
0
        public TransactionResult AddManyToManyRelations(ManyToManyRelation attribute, object sourceId, IDictionary models)
        {
            TransactionResult result = new TransactionResult(SQLiteErrorCode.Ok, null);

            if (models != null)
            {
                foreach (object targetId in models.Keys)
                {
                    var query = string.Format("INSERT INTO {0} ({1}, {2}) VALUES('{3}', '{4}')",
                                              attribute.JoinTable,
                                              attribute.JoinSourceId,
                                              attribute.JoinTargetId,
                                              sourceId,
                                              targetId
                                              );

                    result = this.WriteQuery(query);
                }
            }

            return(result);
        }