public ActiveRecordPropertyDescriptor[] InferProperties(TableDefinition tableDef)
        {
            ArrayList list = new ArrayList();

            foreach (ColumnDefinition col in tableDef.Columns)
            {
                if (col.ForeignKey)
                {
                    continue;
                }

                String propertyName = _namingService.CreatePropertyName(col.Name);
                Type   propertyType = _typeInfService.ConvertOleType(col.Type);
                String colType      = col.Type.ToString();
                String colName      = col.Name;

                ActiveRecordFieldDescriptor field = null;

                if (col.PrimaryKey)
                {
                    field = new ActiveRecordPrimaryKeyDescriptor(
                        colName, colType, propertyName, propertyType, "Native");
                }
                else
                {
                    field = new ActiveRecordFieldDescriptor(
                        colName, colType, propertyName, propertyType, col.Nullable);
                }

                list.Add(field);
            }

            return((ActiveRecordFieldDescriptor[])list.ToArray(typeof(ActiveRecordFieldDescriptor)));
        }
Beispiel #2
0
        public void CreatePropertyName()
        {
            INamingService service = (INamingService)Kernel[typeof(INamingService)];

            Assert.AreEqual("OrderName", service.CreatePropertyName("order_name"));
            Assert.AreEqual("Name", service.CreatePropertyName("name"));
            Assert.AreEqual("CustomerName", service.CreatePropertyName("customerName"));
            Assert.AreEqual("CustomerName", service.CreatePropertyName("customer_Name"));
            Assert.AreEqual("CustomerName", service.CreatePropertyName("Customer_name"));
            Assert.AreEqual("Name", service.CreatePropertyName("_name"));
        }