示例#1
0
        public void Get_Names_Test()
        {
            // Setup
            string expected1 = nameof(TestEntity.ReferenceTypeProperty).ToLower();
            string expected2 = nameof(TestEntity.ValueTypeProperty).ToLower();

            // Act
            List <string> actual = LogicalName.GetNames <TestEntity>(
                t => t.ReferenceTypeProperty,
                t => t.ValueTypeProperty);

            // Assert
            Assert.AreEqual(2, actual.Count);
            Assert.AreEqual(expected1, actual[0]);
            Assert.AreEqual(expected2, actual[1]);
        }
示例#2
0
        public void Get_Name_For_Oob_Generated()
        {
            // Setup
            string expectedString    = nameof(Account.AccountNumber).ToLowerInvariant();
            string expectedDouble    = nameof(Account.Address1_Longitude).ToLowerInvariant();
            string expectedOptionSet = nameof(Account.AccountRatingCode).ToLowerInvariant();
            string expectedInt       = nameof(Account.Address1_UTCOffset).ToLowerInvariant();
            string expectedMoney     = nameof(Account.CreditLimit).ToLowerInvariant();
            string expectedBool      = nameof(Account.CreditOnHold).ToLowerInvariant();
            string expectedDate      = nameof(Account.CreatedOn).ToLowerInvariant();
            string expectedGuid      = nameof(Account.AccountId).ToLowerInvariant();
            string expectedReference = nameof(Account.PrimaryContactId).ToLowerInvariant();
            string expectedDecimal   = nameof(Account.ExchangeRate).ToLowerInvariant();

            // Act
            List <string> actual = LogicalName.GetNames <Account>(
                a => a.AccountNumber,
                a => a.Address1_Longitude,
                a => a.AccountRatingCode,
                a => a.Address1_UTCOffset,
                a => a.CreditLimit,
                a => a.CreditOnHold,
                a => a.CreatedOn,
                a => a.AccountId,
                a => a.PrimaryContactId,
                a => a.ExchangeRate);

            // Assert
            Assert.AreEqual(expectedString, actual[0]);
            Assert.AreEqual(expectedDouble, actual[1]);
            Assert.AreEqual(expectedOptionSet, actual[2]);
            Assert.AreEqual(expectedInt, actual[3]);
            Assert.AreEqual(expectedMoney, actual[4]);
            Assert.AreEqual(expectedBool, actual[5]);
            Assert.AreEqual(expectedDate, actual[6]);
            Assert.AreEqual(expectedGuid, actual[7]);
            Assert.AreEqual(expectedReference, actual[8]);
            Assert.AreEqual(expectedDecimal, actual[9]);
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the ColumnSet<T> class setting the Columns property.
 /// </summary>
 /// <param name="columns">Specifies an array of property expressions containing the names of the attributes.
 /// </param>
 public ColumnSet(params Expression <Func <T, object> >[] columns)
 {
     Columns = LogicalName.GetNames(columns);
 }
示例#4
0
 /// <summary>
 /// Adds the specified attributes to the column set.
 /// </summary>
 /// <param name="columns">Specifies an array of property expressions containing the names of the attributes.</param>
 public void AddColumns(params Expression <Func <T, object> >[] columns)
 {
     Columns.AddRange(LogicalName.GetNames(columns));
 }
示例#5
0
 /// <summary>
 /// Adds the specified attributes to the column set.
 /// </summary>
 /// <typeparam name="T">Type of the entity to add column from</typeparam>
 /// <param name="column">The property expressions containing the name of the attribute to add</param>
 public static void AddColumns <T>(this ColumnSet columnSet, params Expression <Func <T, object> >[] columns) where T : Entity
 {
     columnSet.AddColumns(LogicalName.GetNames(columns)?.ToArray());
 }