/// <summary> /// Inserts the object in databse and sets its Id property to the inserted record id. /// </summary> /// <param name="vo">The VO object to be inserted.</param> /// <returns>The inserted record id. -1 if the insertion was not successful.</returns> public virtual int Insert(T vo) { string[] columnsNames = ConvertColumnNamesToArray(); string statement = SqlStatememtGenerator.Insert(tableName, columnsNames); SqlCeParameter[] parameters = MakeSqlParameters(vo); if (!executer.ExecuteInsertStatement(statement, parameters)) return -1; int id = GetMaxId(); vo.Id = id; return id; }
public int Attach(T1 firstTableVO, T2 secondTableVO) { string statement = SqlStatememtGenerator.Insert(tableName, ConvertToArray(firstTableIdColumnName, secondTableIdColumnName)); SqlCeParameter[] parameters = new SqlCeParameter[2]; parameters[0] = MakeSqlParameter(firstTableIdColumnName, firstTableVO.Id); parameters[1] = MakeSqlParameter(secondTableIdColumnName, secondTableVO.Id); if (!executer.ExecuteInsertStatement(statement, parameters)) { return(-1); } return(GetMaxId()); }