/// <summary>Clones this instance.</summary>
        /// <returns>A clone of this instance</returns>
        public override DataTable Clone()
        {
            MessagesInThreadTypedList cloneToReturn = ((MessagesInThreadTypedList)(base.Clone()));

            cloneToReturn.InitMembers();
            return(cloneToReturn);
        }
Exemple #2
0
		/// <summary>
		/// Constructs a TypedList with all the messages in the thread given. Poster info is included, so the
		/// returned dataview is bindable at once to the message list repeater.
		/// </summary>
		/// <param name="threadID">ID of Thread which messages should be returned</param>
		/// <param name="pageNo">The page no.</param>
		/// <param name="pageSize">Size of the page.</param>
		/// <returns>TypedList with all messages in the thread for the page specified</returns>
		public static MessagesInThreadTypedList GetAllMessagesInThreadAsTypedList(int threadID, int pageNo, int pageSize)
		{
			// we'll use a typedlist, MessagesInThread to pull the necessary data from the db. The typedlist contains fields from
			// message, user and usertitle. 
			MessagesInThreadTypedList messages = new MessagesInThreadTypedList(); 

			//create the filter with the threadID passed to the method.
			PredicateExpression filter = new PredicateExpression(MessageFields.ThreadID == threadID);

			// Sort Messages on posting date, ascending, so the first post is located on top. 
			SortExpression sorter = new SortExpression(MessageFields.PostingDate.Ascending());

			// fetch the data into the typedlist. Pass in the paging information as well, to perform server-side paging. 
			messages.Fill(0, sorter, true, filter, null, null, pageNo, pageSize);

			// update thread entity directly inside the DB with a non-transactional update statement so the # of views is increased by one.
			ThreadEntity updater = new ThreadEntity();
			// set the NumberOfViews field to an expression which increases it by 1
			updater.Fields[(int)ThreadFieldIndex.NumberOfViews].ExpressionToApply = (ThreadFields.NumberOfViews + 1);
			updater.IsNew = false;

			// update the entity directly, and filter on the PK
			ThreadCollection threads = new ThreadCollection();
			threads.UpdateMulti(updater, (ThreadFields.ThreadID == threadID));
			
			// return the constructed typedlist
			return messages;
		}
 /// <summary>CTor</summary>
 /// <param name="rowBuilder">Row builder object to use when building this row</param>
 protected internal MessagesInThreadRow(DataRowBuilder rowBuilder) : base(rowBuilder)
 {
     _parent = ((MessagesInThreadTypedList)(this.Table));
 }