Exemple #1
0
        public void Start(string prefix, MappedPropertyInfo item)
        {
            HbmSet              set       = item.HbmObject <HbmSet>();
            MappedPropertyInfo  childItem = new MappedPropertyInfo(set.Item, item.FileName);
            PropertyMappingType subType   = childItem.Type;

            if (subType == PropertyMappingType.ManyToMany)
            {
                _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasManyToMany, item.ReturnType, item.Name));
                _builder.AddLine(string.Format(".{0}(\"{1}\")", KeyColumn.FluentNHibernateNames.ChildKeyColumn, childItem.ColumnName));
            }
            else if (subType == PropertyMappingType.OneToMany)
            {
                _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasMany, item.ReturnType, item.Name));
            }
            else
            {
                _builder.StartMethod(prefix, "set?(x => x" + item.Name + ")");
            }
            _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.AsSet));
            _keyColumn.Add(set.inverse, item.ColumnName, subType);
            _lazyLoad.Add(set.lazySpecified, set.lazy);
            _table.Add(set.table);
            _inverse.Add(set.inverse);
            _cascade.Add(set.cascade);
            _fetch.Add(set.fetch);
            _orderBy.Add(set.orderby);
            _where.Add(set.where);
            _cacheBuilder.Add(set.cache);
        }
Exemple #2
0
        public void Start(string prefix, MappedPropertyInfo item)
        {
            HbmBag bag = item.HbmObject <HbmBag>();
            PropertyMappingType subType = new MappedPropertyInfo(bag.Item, item.FileName).Type;

            if (subType == PropertyMappingType.ManyToMany)
            {
                _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasManyToMany, item.ReturnType, item.Name));
            }
            else if (subType == PropertyMappingType.OneToMany)
            {
                _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasMany, item.ReturnType, item.Name));
            }
            else
            {
                _builder.StartMethod(prefix, "bag?(x => x" + item.Name + ")");
            }
            _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.AsBag));
            _keyColumn.Add(bag.inverse, item.ColumnName, subType);
            _lazyLoad.Add(bag.lazySpecified, bag.lazy);
            _table.Add(bag.table);
            _inverse.Add(bag.inverse);
            _cascade.Add(bag.cascade);
            _fetch.Add(bag.fetch);
            _orderBy.Add(bag.orderby);
            _where.Add(bag.where);
            _cacheBuilder.Add(bag.cache);
        }
        public void Add(MappedPropertyInfo info)
        {
            if (info.Type != PropertyMappingType.Id)
            {
                return;
            }

            HbmId id = info.HbmObject<HbmId>();
            HbmGenerator generator = id.generator;
            if (generator != null)
            {
                switch (generator.@class)
                {
                    case "sequence":
                        {
                            HbmParam[] parameters = generator.param;
                            string[] text = parameters[0].Text;
                            _builder.AddLine(string.Format(".{0}.{1}(\"{2}\")", FluentNHibernateNames.GeneratedBy, FluentNHibernateNames.Sequence, text[0]));
                            break;
                        }
                    case "assigned":
                        _builder.AddLine(string.Format(".{0}.{1}()", FluentNHibernateNames.GeneratedBy, FluentNHibernateNames.Assigned));
                        break;
                    case "native":
                        _builder.AddLine(string.Format(".{0}.{1}()", FluentNHibernateNames.GeneratedBy, FluentNHibernateNames.Native));
                        break;
                    default:
                        _builder.AddLine(string.Format(".{0}. ?", FluentNHibernateNames.GeneratedBy));
                        break;
                }
            }
        }
Exemple #4
0
 public void Start(string prefix, MappedPropertyInfo item)
 {
     _builder.StartMethod(prefix, string.Format("{0}(x => x.{1})", FluentNHibernateNames.Id, item.Name));
     _column.Add(item);
     _generatedBy.Add(item);
     _unsavedValue.Add(item);
 }
        public void Start(string prefix, MappedPropertyInfo item)
        {
            CodeFileBuilder componentBuilder = new CodeFileBuilder();
            componentBuilder.Indent(5);
            const string subPrefix = "y.";
            HbmCompositeElement component = item.HbmObject<HbmCompositeElement>();
            componentBuilder.AddLine("");

            var componentBodyBuilder = new ClassMapBody(componentBuilder);
            foreach (var componentPart in component.Items)
            {
                componentBodyBuilder.Add(subPrefix, new MappedPropertyInfo(componentPart, item.FileName));
            }
            _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2}, y=>", FluentNHibernateNames.CompositeElement, item.ReturnType, item.Name));
            _builder.AddLine("{");
            _builder.AddLine(componentBuilder.ToString());
            _builder.AddLine("})");
            /*if (component. )
            {
                _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Insert));
            }
            if (component.update)
            {
                _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Update));
            }*/
        }
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_Bag()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmBag(), null);
     _column.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_not_Property()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmComponent(), null);
     _customType.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
Exemple #8
0
 public void Start(string prefix, MappedPropertyInfo item)
 {
     HbmBag bag = item.HbmObject<HbmBag>();
     PropertyMappingType subType = new MappedPropertyInfo(bag.Item, item.FileName).Type;
     if (subType == PropertyMappingType.ManyToMany)
     {
         _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasManyToMany, item.ReturnType, item.Name));
     }
     else if (subType == PropertyMappingType.OneToMany)
     {
         _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasMany, item.ReturnType, item.Name));
     }
     else
     {
         _builder.StartMethod(prefix, "bag?(x => x" + item.Name + ")");
     }
     _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.AsBag));
     _keyColumn.Add(bag.inverse, item.ColumnName, subType);
     _lazyLoad.Add(bag.lazySpecified, bag.lazy);
     _table.Add(bag.table);
     _inverse.Add(bag.inverse);
     _cascade.Add(bag.cascade);
     _orderBy.Add(bag.orderby);
     _cacheBuilder.Add(bag.cache);
 }
Exemple #9
0
        public void Start(string prefix, MappedPropertyInfo item)
        {
            CodeFileBuilder componentBuilder = new CodeFileBuilder();

            componentBuilder.Indent(5);
            const string subPrefix = "y.";
            HbmComponent component = item.HbmObject <HbmComponent>();

            componentBuilder.AddLine("");

            var componentBodyBuilder = new ClassMapBody(componentBuilder);

            foreach (var componentPart in component.Items)
            {
                componentBodyBuilder.Add(subPrefix, new MappedPropertyInfo(componentPart, item.FileName));
            }
            _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2}, y=>", FluentNHibernateNames.Component, item.ReturnType, item.Name));
            _builder.AddLine("{");
            _builder.AddLine(componentBuilder.ToString());
            _builder.AddLine("})");
            if (component.insert)
            {
                _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Insert));
            }
            if (component.update)
            {
                _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Update));
            }
        }
Exemple #10
0
 public void Start(string prefix, MappedPropertyInfo item)
 {
     _builder.StartMethod(prefix, string.Format("{0}(x => x.{1})", FluentNHibernateNames.Id, item.Name));
     _column.Add(item);
     _generatedBy.Add(item);
     _unsavedValue.Add(item);
 }
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_not_Id()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmSet(), null);
     _unsavedValue.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
Exemple #12
0
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_length_is_null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty(), null);
     _length.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
Exemple #13
0
 public void Start(string prefix, MappedPropertyInfo item)
 {
     HbmSet set = item.HbmObject<HbmSet>();
     MappedPropertyInfo childItem = new MappedPropertyInfo(set.Item, item.FileName);
     PropertyMappingType subType = childItem.Type;
     if (subType == PropertyMappingType.ManyToMany)
     {
         _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasManyToMany, item.ReturnType, item.Name));
         _builder.AddLine(string.Format(".{0}(\"{1}\")", KeyColumn.FluentNHibernateNames.ChildKeyColumn, childItem.ColumnName));
     }
     else if (subType == PropertyMappingType.OneToMany)
     {
         _builder.StartMethod(prefix, string.Format("{0}<{1}>(x => x.{2})", FluentNHibernateNames.HasMany, item.ReturnType, item.Name));
     }
     else
     {
         _builder.StartMethod(prefix, "set?(x => x" + item.Name + ")");
     }
     _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.AsSet));
     _keyColumn.Add(set.inverse, item.ColumnName, subType);
     _lazyLoad.Add(set.lazySpecified, set.lazy);
     _table.Add(set.table);
     _inverse.Add(set.inverse);
     _cascade.Add(set.cascade);
     _orderBy.Add(set.orderby);
     _where.Add(set.where);
 }
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_not_Property()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmComponent(), null);

                _customType.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #15
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is__Id()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId(), null);

                _unique.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #16
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_Id_and_generator_is_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId(), null);

                _generatedBy.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #17
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_length_is_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty(), null);

                _length.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #18
0
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_unique_is_null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             updateSpecified = false
         }, null);
     _unique.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
Exemple #19
0
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_valid_and_UniqueIndex_is_null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             index = null
         }, null);
     _index.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_ReturnType_is_not__YesNo()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             type1 = "System.String"
         }, null);
     _customType.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_not_Id_and_unsavedvalue_is__null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId
         {
             unsavedvalue = "null"
         }, null);
     _unsavedValue.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}(String.Empty)\r\n", UnsavedValue.FluentNHibernateNames.UnsavedValue));
 }
 public void Should_return_empty_given_MappedPropertyInfo_Type_is_valid_and_CanBeNull_is_null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             notnullSpecified = false
         }, null);
     _nullability.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo("");
 }
Exemple #23
0
 public void Add(MappedPropertyInfo item)
 {
     if (item.Type != PropertyMappingType.Property)
     {
         return;
     }
     if (item.MaxLength != null)
     {
         _builder.AddLine(string.Format(".{0}({1})", FluentNHibernateNames.Length, item.MaxLength));
     }
 }
Exemple #24
0
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_unique_is_not_null()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             updateSpecified = true,
             unique = true
         }, null);
     _unique.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}()\r\n", Unique.FluentNHibernateNames.Unique));
 }
Exemple #25
0
 public void Add(MappedPropertyInfo item)
 {
     if (item.Type != PropertyMappingType.Property)
     {
         return;
     }
     if (item.MaxLength != null)
     {
         _builder.AddLine(string.Format(".{0}({1})", FluentNHibernateNames.Length, item.MaxLength));
     }
 }
Exemple #26
0
 public void Add(MappedPropertyInfo info)
 {
     if (info.Type == PropertyMappingType.Id)
     {
         return;
     }
     if (info.IsUnique != null && info.IsUnique.Value)
     {
         _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Unique));
     }
 }
Exemple #27
0
 public void Add(MappedPropertyInfo info)
 {
     if (info.Type == PropertyMappingType.Id)
     {
         return;
     }
     if (info.UniqueIndex != null)
     {
         _builder.AddLine(string.Format(".{0}(\"{1}\")", FluentNHibernateNames.Index, info.UniqueIndex));
     }
 }
Exemple #28
0
 public void Add(MappedPropertyInfo info)
 {
     if (info.Type == PropertyMappingType.Id)
     {
         return;
     }
     if (info.IsUnique != null && info.IsUnique.Value)
     {
         _builder.AddLine(string.Format(".{0}()", FluentNHibernateNames.Unique));
     }
 }
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_valid_and_CanBeNull_is_false()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             notnullSpecified = true,
             notnull = true
         }, null);
     _nullability.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}.{1}()\r\n", Nullability.FluentNHibernateNames.Not, Nullability.FluentNHibernateNames.Nullable));
 }
Exemple #30
0
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_length_is_not_null()
 {
     const string length = "6";
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             length = length
         }, null);
     _length.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}({1})\r\n", Length.FluentNHibernateNames.Length, length));
 }
Exemple #31
0
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_valid_and_UniqueIndex_is_not_null()
 {
     const string index = "FirstName";
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             index = index
         }, null);
     _index.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}(\"{1}\")\r\n", Index.FluentNHibernateNames.Index, index));
 }
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_not_Id_and_unsavedvalue_is_not__null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId
                {
                    unsavedvalue = "6"
                }, null);

                _unsavedValue.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}(6)\r\n", UnsavedValue.FluentNHibernateNames.UnsavedValue));
            }
Exemple #33
0
            public void BeforeEachTest()
            {
                const string input = @"
					<many-to-one name=""CourtTypeCode"" class=""Mvba.Enterprise.Business.Code, Mvba.Enterprise.Business"">
						<column name=""COURT_TYPE_CODE_ID"" sql-type=""NUMBER"" not-null=""true"" index=""IX_COURT_COURTTYPECODEID""/>
					</many-to-one>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
Exemple #34
0
            public void BeforeEachTest()
            {
                const string input = @"
					<many-to-one name=""State"" class=""Mvba.Enterprise.Business.State, Mvba.Enterprise.Business"">
						<column name=""`STATE`"" length=""2"" sql-type=""VARCHAR2"" not-null=""true""/>
					</many-to-one>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_SqlType_is_not__CHAR()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    column = "VARCHAR2"
                }, null);

                _customType.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_ReturnType_is_not__YesNo()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    type1 = "System.String"
                }, null);

                _customType.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #37
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_valid_and_UniqueIndex_is_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    index = null
                }, null);

                _index.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
 public void BeforeEachTest()
 {
     const string input = @"
         <id name=""StateCode"" type=""String"" unsaved-value=""null"">
             <column name=""STATE_CODE"" length=""2"" sql-type=""VARCHAR2"" not-null=""true"" unique=""true"" index=""PK_STATES""/>
             <generator class=""assigned"" />
         </id>";
     _info = HbmFileUtility.LoadFromString(@"
         <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
             <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">" + input + @"</class>
         </hibernate-mapping>").Properties[0];
 }
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_valid_and_CanBeNull_is_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    notnullSpecified = false
                }, null);

                _nullability.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
Exemple #40
0
        public void Add(MappedPropertyInfo item)
        {
            if (item.Type != PropertyMappingType.Property)
            {
                return;
            }

            if (item.SqlType == "CHAR" && item.ReturnType == "YesNo")
            {
                _builder.AddLine(string.Format(".{0}(\"{1}\")", FluentNHibernateNames.CustomType, item.ReturnType));
            }
        }
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_length_is_not_null()
 {
     const string yesNo = "YesNo";
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
         {
             column = "CHAR",
             type1 = yesNo
         }, null);
     _customType.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}(\"{1}\")\r\n", CustomType.FluentNHibernateNames.CustomType, yesNo));
 }
Exemple #42
0
            public void Should_return_empty_given_MappedPropertyInfo_Type_is_Property_and_unique_is_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    updateSpecified = false
                }, null);

                _unique.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo("");
            }
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_not_Id_and_generator_class_is__assigned()
 {
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId
         {
             generator = new HbmGenerator
                 {
                     @class = "assigned"
                 }
         }, null);
     _generatedBy.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(String.Format(".{0}.{1}()\r\n", GeneratedBy.FluentNHibernateNames.GeneratedBy, GeneratedBy.FluentNHibernateNames.Assigned));
 }
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_valid_and_CanBeNull_is_false()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    notnullSpecified = true,
                    notnull          = true
                }, null);

                _nullability.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}.{1}()\r\n", Nullability.FluentNHibernateNames.Not, Nullability.FluentNHibernateNames.Nullable));
            }
Exemple #45
0
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_unique_is_not_null()
            {
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    updateSpecified = true,
                    unique          = true
                }, null);

                _unique.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}()\r\n", Unique.FluentNHibernateNames.Unique));
            }
Exemple #46
0
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_length_is_not_null()
            {
                const string       length             = "6";
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    length = length
                }, null);

                _length.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}({1})\r\n", Length.FluentNHibernateNames.Length, length));
            }
Exemple #47
0
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_valid_and_UniqueIndex_is_not_null()
            {
                const string       index = "FirstName";
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    index = index
                }, null);

                _index.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}(\"{1}\")\r\n", Index.FluentNHibernateNames.Index, index));
            }
Exemple #48
0
            public void BeforeEachTest()
            {
                const string input = @"
					<id name=""StateCode"" type=""String"" unsaved-value=""null"">
						<column name=""STATE_CODE"" length=""2"" sql-type=""VARCHAR2"" not-null=""true"" unique=""true"" index=""PK_STATES""/>
						<generator class=""assigned"" />
					</id>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
Exemple #49
0
            public void BeforeEachTest()
            {
                const string input = @"
					<set name=""TaxRecords"" inverse=""true"" cascade=""none""  table=""TAX_CALC_FILTER"" lazy=""true""  outer-join=""false"">
						<key column=""TAX_CALC_RUN_ID""/>
						<many-to-many  column=""SPTD_ID"" class=""Mvba.Enterprise.Business.TaxRecord, Mvba.Enterprise.Business""/>
					</set>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
Exemple #50
0
            public void BeforeEachTest()
            {
                const string input = @"
					<bag name=""Clerks"" inverse=""true"" table=""CLERK"" lazy=""true"" order-by=""FIRST_NAME"">
						<key column =""COUNTY_ID""/>
						<one-to-many class=""Mvba.Enterprise.Business.Clerk, Mvba.Enterprise.Business""/>
					</bag>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
Exemple #51
0
            public void BeforeEachTest()
            {
                const string input = @"

					<property name=""LastName"" type=""String"">
						<column name=""LAST_NAME"" length=""50"" sql-type=""VARCHAR2"" not-null=""true""/>
					</property>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
        public void Add(MappedPropertyInfo info)
        {
            if (info.Type != PropertyMappingType.Id)
            {
                return;
            }

            HbmId id = info.HbmObject<HbmId>();
            if (id.unsavedvalue != null)
            {
                var unsavedValue = id.unsavedvalue == "null" ? "String.Empty" : id.unsavedvalue;
                _builder.AddLine(string.Format(".{0}({1})", FluentNHibernateNames.UnsavedValue, unsavedValue));
            }
        }
Exemple #53
0
 public void Add(MappedPropertyInfo item)
 {
     if (item.Type == PropertyMappingType.Component ||
         item.Type == PropertyMappingType.Property ||
         item.Type == PropertyMappingType.Set ||
         item.Type == PropertyMappingType.Bag)
     {
         return;
     }
     if (item.ColumnName != null)
     {
         _builder.AddLine(string.Format(".{0}(\"{1}\")", FluentNHibernateNames.Column, item.ColumnName));
     }
 }
            public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Property_and_length_is_not_null()
            {
                const string       yesNo = "YesNo";
                MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmProperty
                {
                    column = "CHAR",
                    type1  = yesNo
                }, null);

                _customType.Add(mappedPropertyInfo);
                string result = _builder.ToString();

                result.ShouldBeEqualTo(string.Format(".{0}(\"{1}\")\r\n", CustomType.FluentNHibernateNames.CustomType, yesNo));
            }
 public void Add(string prefix, MappedPropertyInfo info)
 {
     var methodBuilders = new List<ICommonMapMethod>
         {
             new Nullability(_builder),
             new Unique(_builder),
             new Index(_builder)
         };
     info.Type.StartMethod(prefix, _builder, info);
     {
         methodBuilders.ForEach(x => x.Add(info));
     }
     EndMap(_builder);
 }
Exemple #56
0
 public void Add(MappedPropertyInfo item)
 {
     if (item.Type == PropertyMappingType.Component ||
         item.Type == PropertyMappingType.Property ||
         item.Type == PropertyMappingType.Set ||
         item.Type == PropertyMappingType.Bag)
     {
         return;
     }
     if (item.ColumnName != null)
     {
         _builder.AddLine(string.Format(".{0}(\"{1}\")", FluentNHibernateNames.Column, item.ColumnName));
     }
 }
Exemple #57
0
            public void BeforeEachTest()
            {
                const string input = @"
					<id name=""CountyId"" type=""Int32"" unsaved-value=""0"">
						<column name=""COUNTY_ID"" sql-type=""NUMBER"" not-null=""true"" unique=""true"" index=""PK_COUNTY""/>
						<generator class=""sequence""> 
							<param name=""sequence"">S_COUNTY_ID</param> 
						</generator> 
					</id>"                    ;

                _info = HbmFileUtility.LoadFromString(@"
					<hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
						<class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">"                         + input + @"</class>
					</hibernate-mapping>"                    ).Properties[0];
            }
Exemple #58
0
 public void Add(MappedPropertyInfo info)
 {
     if (info.Type == PropertyMappingType.Id ||
         info.Type == PropertyMappingType.Set ||
         info.Type == PropertyMappingType.Bag)
     {
         return;
     }
     if (info.CanBeNull != null)
     {
         if (!info.CanBeNull.Value)
         {
             _builder.AddLine(string.Format(".{0}.{1}()", FluentNHibernateNames.Not, FluentNHibernateNames.Nullable));
         }
     }
 }
Exemple #59
0
 public void Should_generate_correct_code_given_MappedPropertyInfo_Type_is_Id_and_columnName_is_not_null()
 {
     const string columnName = "FirstName";
     MappedPropertyInfo mappedPropertyInfo = new MappedPropertyInfo(new HbmId
         {
             column = new[]
                 {
                     new HbmColumn
                         {
                             name = columnName
                         }
                 }
         }, null);
     _column.Add(mappedPropertyInfo);
     string result = _builder.ToString();
     result.ShouldBeEqualTo(string.Format(".{0}(\"{1}\")\r\n", Column.FluentNHibernateNames.Column, columnName));
 }
 public void BeforeEachTest()
 {
     const string input = @"
         <bag name=""Clerks"" inverse=""true"" table=""CLERK"" lazy=""true"" order-by=""FIRST_NAME"">
             <key column =""COUNTY_ID""/>
             <one-to-many class=""Mvba.Enterprise.Business.Clerk, Mvba.Enterprise.Business""/>
         </bag>";
     _info = HbmFileUtility.LoadFromString(@"
         <hibernate-mapping xmlns=""urn:nhibernate-mapping-2.2"">
             <class name=""Mvba.Enterprise.Business.User, Mvba.Enterprise.Business"" table=""USERS"">" + input + @"</class>
         </hibernate-mapping>").Properties[0];
 }