Esempio n. 1
0
        /// <summary>
        /// Gets first 5000 Active Entities where the values are in the columnName
        /// </summary>
        /// <param name="service"></param>
        /// <param name="logicalName">The LogicalName of the Entity to query.</param>
        /// <param name="columnName">The name of the column to perform the in against.</param>
        /// <param name="values">The list of values to search for being in the column name.</param>
        /// <returns></returns>
        public static List <Entity> GetEntitiesIn(this IOrganizationService service, string logicalName,
                                                  string columnName, params object[] values)
        {
            var settings = new LateBoundQuerySettings(logicalName);

            return(service.RetrieveMultiple(settings.CreateInExpression(columnName, values)).Entities.ToList());
        }
Esempio n. 2
0
        /// <summary>
        /// Gets first 5000 Active Entities (with the given subset of columns only)
        /// where the values are in the columnName
        /// </summary>
        /// <param name="service"></param>
        /// <param name="logicalName">The LogicalName of the Entity to query.</param>
        /// <param name="columnSet">Columns to Return.</param>
        /// <param name="columnName">The name of the column to perform the in against.</param>
        /// <param name="values">The list of values to search for being in the column name.</param>
        /// <returns></returns>
        public static List <Entity> GetEntitiesIn(this IOrganizationService service, string logicalName,
                                                  ColumnSet columnSet, string columnName, IEnumerable values)
        {
            var settings = new LateBoundQuerySettings(logicalName)
            {
                Columns = columnSet,
            };

            return(service.RetrieveMultiple(settings.CreateInExpression(columnName, values)).Entities.ToList());
        }
        /// <summary>
        /// Retreives the first Active entity (with the given subset of columns only)
        /// where the columnNameAndValue Pairs match
        /// </summary>
        /// <param name="service"></param>
        /// <param name="logicalName"></param>
        /// <param name="columnSet">Columns to retrieve</param>
        /// <param name="columnNameAndValuePairs">List of pairs that look like this:
        /// (string name of the column, value of the column) ie. "name","John Doe" goes to entity.name = "John Doe"
        /// </param>
        /// <returns></returns>
        public static Entity GetFirstOrDefault(this IOrganizationService service, string logicalName, ColumnSet columnSet,
                                               params object[] columnNameAndValuePairs)
        {
            var settings = new LateBoundQuerySettings(logicalName)
            {
                Columns = columnSet,
                First   = true
            };

            return(service.RetrieveMultiple(settings.CreateExpression(columnNameAndValuePairs)).Entities.FirstOrDefault());
        }