예제 #1
0
        public DBRow AddOrReplaceRow(DBRow row)
        {
            if (row.Table == this)
            {
                throw new InvalidOperationException("Row is already in this table.");
            }

            DBRow sameRow = FindRow(row);

            if (sameRow != null)
            {
                if (sameRow.Element("version") != null && row.Element("version") != null)
                {
                    row.Element("version").Value = sameRow.Element("version").Value;
                }
                if (sameRow.Element("_version") != null && row.Element("_version") != null)
                {
                    row.Element("_version").Value = sameRow.Element("_version").Value;
                }

                sameRow.Remove();
            }

            return(AddRow(row));
        }
예제 #2
0
        /// <summary>
        /// Searches for a row with id element same as specified row id element.
        /// </summary>
        /// <param name="row">The row to search for.</param>
        /// <returns>First row that has id same as specified row id element.</returns>
        public DBRow FindRow(DBRow row)
        {
            if (this.rows.Contains(row) == true)
            {
                return(row);
            }

            return(FindRow(row.Element("id").Value));
        }
예제 #3
0
        /// <summary>
        /// Searches for a row with id element same as specified row id element.
        /// </summary>
        /// <param name="row">The row to search for.</param>
        /// <returns>First row that has id same as specified row id element.</returns>
        public DBRow FindRow(DBRow row)
        {
            var machingRow = (from table in this.tables select table.FindRow(row)).FirstOrDefault(r => r != null);

            //TODO -1 czy tego nie mozna wywalic? przeciez DBTable robi porownianie po id jak nie znajdzie takiej samej ref
            //wiec to powoduje podwojne szukanie
            if (machingRow != null)
            {
                return(machingRow);
            }
            else
            {
                return(FindRow(row.Element("id").Value));
            }
        }
예제 #4
0
        /// <summary>
        /// Searches for a row with id element same as specified row id element.
        /// </summary>
        /// <param name="row">The row to search for.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <returns>
        /// First row that has id same as specified row id element.
        /// </returns>
        public DBRow FindRow(DBRow row, string tableName)
        {
            var machingRow = (from table in this.tables
                              where table.Name.Equals(tableName, StringComparison.Ordinal)
                              select table.FindRow(row)).FirstOrDefault(r => r != null);

            if (machingRow != null)
            {
                return(machingRow);
            }
            else
            {
                return(FindRow(row.Element("id").Value, tableName));
            }
        }
예제 #5
0
파일: DBRow.cs 프로젝트: MakoLab/fractus
 /// <summary>
 /// Determines whether this row is the same as the specified row by comparing rows version element.
 /// </summary>
 /// <param name="row">The row to compare against.</param>
 /// <returns>
 ///     <c>true</c> if this row is the same as the specified row; otherwise, <c>false</c>.
 /// </returns>
 public bool IsTheSameAs(DBRow row)
 {
     return(this.Element("version").Value.Equals(row.Element("version").Value, StringComparison.OrdinalIgnoreCase));
 }