internal void MapProperties(Type instanceType, StructuralTypeConfiguration configuration)
        {
            var metaDatas = query.GetMetadataFor(instanceType).Properties;

            foreach (var data in metaDatas)
            {
                if (data.ModelName == null)
                {
                    continue;
                }
                if (!data.StringLength.HasValue && !data.Required.HasValue)
                {
                    continue;
                }
                var methodInfo = methodMapping.GetPropertyMappingMethod(configuration.GetType(), instanceType,
                                                                        data.ModelType);
                if (methodInfo == null)
                {
                    continue;
                }

                var lambda = generator.CreateExpressionForProperty(instanceType, data.ModelName);
                if (lambda != null)
                {
                    var propertyConfiguration = (PropertyConfiguration)methodInfo.Invoke(configuration, new[] { lambda });

                    factory.Create(propertyConfiguration).Convert(data, propertyConfiguration);
                }
            }
        }
Ejemplo n.º 2
0
        internal void MapProperties <T>(StructuralTypeConfiguration <T> configuration) where T : class
        {
            var metaDatas = QueryFluentMetadata.GetMetadataFor(typeof(T)).Properties;

            foreach (var data in metaDatas)
            {
                if (data.ModelName == null)
                {
                    continue;
                }
                if (!data.GetMaximumLength().HasValue&& !data.Required.HasValue)
                {
                    continue;
                }
                var methodInfo = PropertyMethodMapping.GetPropertyMappingMethod(
                    configuration.GetType(),
                    typeof(T),
                    data.ModelType);
                if (methodInfo == null)
                {
                    continue;
                }

                var lambda = ExpressionGenerator.CreateExpressionForProperty(typeof(T), data.ModelName);
                if (lambda != null)
                {
                    var propertyConfiguration = (PrimitivePropertyConfiguration)methodInfo.Invoke(configuration, new[] { lambda });

                    factory.Create(propertyConfiguration).Convert(data, propertyConfiguration);
                }
            }
        }
 public void Generate_for_Id()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(ContentBase), "Id"));
 }
 public void Generate_for_WebSite()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(Content), "WebSite"));
 }
 public void Generate_for_Comments()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(Content), "Comments"));
 }
 public void Generate_for_Author()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(Content), "Author"));
 }
Ejemplo n.º 7
0
 public void Generate_for_Username()
 {
     Assert.NotNull(generator.CreateExpressionForProperty(typeof(WebUser), "Username"));
 }
 public void Generate_for_ConfirmationKey()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(WebUser), "ConfirmationKey"));
 }
 public void Generate_for_LastLogin()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(WebUser), "LastLogin"));
 }
 public void Generate_for_BountCount()
 {
     Assert.NotNull(ExpressionGenerator.CreateExpressionForProperty(typeof(WebUser), "Confirmed"));
 }
 public void Wont_Generate_for_Dummy()
 {
     Assert.Null(ExpressionGenerator.CreateExpressionForProperty(typeof(WebUser), "Dummy"));
 }