linkentityhelpercollection.cs

来自「CRM的移动平台代码」· CS 代码 · 共 84 行

CS
84
字号
using System;
using Microsoft.Crm.Sandbox.Mobile.CrmServiceSdk;
using Microsoft.Crm.Sandbox.Mobile.Helpers;

namespace Microsoft.Crm.Sandbox.Mobile.Helpers.Collection
{
	public class LinkEntityHelperCollection : System.Collections.CollectionBase
	{
		// Fields
		private string _fromEntityName;

		#region Properties

		/// <summary>
		/// The entity that is being mapped from
		/// </summary>
		public string FromEntityName
		{
			get
			{
				return _fromEntityName;
			}
		}

		/// <summary>
		/// Provides access to the underlying collection of LinkEntityHelpers
		/// </summary>
		public LinkEntityHelper this[int index]
		{
			get
			{
				return (LinkEntityHelper)List[index];
			}
		}

		#endregion

		#region Constructor

		/// <summary>
		/// Used to create a collection of LinkEntityHelper objects
		/// </summary>
		/// <param name="fromEntityName">Specifies the entity that is being mapped from</param>
		public LinkEntityHelperCollection(string fromEntityName)
		{
			_fromEntityName = fromEntityName;
		}

		#endregion

		#region Methods

		/// <summary>
		/// Used to add a linked entity to the collection
		/// </summary>
		/// <param name="fromAttributeName">Specifies the attribute that is being mapped from in the query</param>
		/// <param name="toEntityName">Specifies the entity that is being mapped to in the query</param>
		/// <param name="toAttributeName">Specifies the attribute that is being mapped to in the query</param>
		/// <returns>A LinkEntityHelper object, that can be stored and used later to add filters</returns>
		public LinkEntityHelper AddLink(string fromAttributeName, string toEntityName, string toAttributeName)
		{
			return AddLink(fromAttributeName, toEntityName, toAttributeName, JoinOperator.Inner);
		}

		/// <summary>
		/// Used to add a linked entity to the collection
		/// </summary>
		/// <param name="fromAttributeName">Specifies the attribute that is being mapped from in the query</param>
		/// <param name="toEntityName">Specifies the entity that is being mapped to in the query</param>
		/// <param name="toAttributeName">Specifies the attribute that is being mapped to in the query</param>
		/// <param name="joinOperator">Specifies how the entities will be joined</param>
		/// <returns>A LinkEntityHelper object, that can be stored and used later to add filters</returns>
		public LinkEntityHelper AddLink(string fromAttributeName, string toEntityName, string toAttributeName, JoinOperator joinOperator)
		{
			LinkEntityHelper linkEntity = new LinkEntityHelper(_fromEntityName, fromAttributeName, toEntityName, toAttributeName, joinOperator);
			List.Add(linkEntity);

			return linkEntity;
		}

		#endregion
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?