/// <summary>
        /// This property will be set only when inserting new entity and will never be set as modified.
        /// </summary>
        /// <returns>The same ExtendedPrimitiveTypeConfiguration instance so that multiple calls can be chained</returns>
        public ExtendedPrimitiveTypeConfiguration NotCompare()
        {
            ExtendedEntityTypeConfiguration.GetInstance()
            .NotCompare(propertyInfo);

            return(this);
        }
コード例 #2
0
        /// <summary>
        /// Configures the unique key property(s) for this entity type.
        /// </summary>
        /// <typeparam name="TKey"> The type of the key. </typeparam>
        /// <param name="keyExpression">
        /// A lambda expression representing the property to be used as the unique key.
        /// C#: t => t.Id VB.Net: Function(t) t.Id If the primary key is made up of multiple properties then specify an anonymous type including the properties.
        /// C#: t => new { t.Id1, t.Id2 }
        /// VB.Net: Function(t) New With { t.Id1, t.Id2 }
        /// </param>
        /// <returns>The same ModelTypeConfiguration instance so that multiple calls can be chained.</returns>
        public ExtendedEntityTypeConfiguration <TEntityType> HasUniqueKey <TKey>(Expression <Func <TEntityType, TKey> > keyExpression)
        {
            if (keyExpression == null)
            {
                throw new ArgumentNullException("keyExpression");
            }

            // Get singleton instance of the configuration
            var modelTypeConfiguration = ExtendedEntityTypeConfiguration.GetInstance();

            // If the return type is anoymous
            if (!keyExpression.ReturnType.IsAnonymousType())
            {
                // Then get property info from member expression
                modelTypeConfiguration.UniqueKey(keyExpression.GetPropertyInfo());
            }
            else
            {
                // Then get properties info from new expression
                modelTypeConfiguration.UniqueKey(keyExpression.GetPropertiesInfo());
            }

            return(this);
        }