Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     table = DetailsDataSource.GetTable();
     Title = table.DisplayName;
     DetailsDataSource.Include = table.ForeignKeyColumnsNames;
     ListHyperLink.NavigateUrl = table.ListActionPath;
 }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------------------------
        protected void Page_Load(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);

               WeavverMaster.SetChatVisibility(true);
               WeavverMaster.FixedWidth = false;
               WeavverMaster.Width = "100%";
               WeavverMaster.FormTitle = table.DisplayName;
               WeavverMaster.FormDescription = GetPageContent("Logistics/Products/Showcase_Description");

               //GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
               //GridView1.RowCreated += new GridViewRowEventHandler(GridView1_RowCreated);
               GridDataSource.EntityTypeFilter = table.EntityType.Name;

               if (table.EntityType.FullName.Contains("Logistics_Products"))
               {
                    if (LoggedInUser == null || LoggedInUser.OrganizationId != SelectedOrganization.OrganizationId)
                    {
                         GridDataSource.WhereParameters.Add(new Parameter("IsPublic", DbType.Boolean, "True"));
                    }
               }
               GridDataSource.WhereParameters.Add(new Parameter("OrganizationId", DbType.Guid, SelectedOrganization.Id.ToString()));

               GridDataSource.OrderBy = "it.Name";

               WeavverMaster.FormTitle = table.DisplayName;
               GridDataSource.Include = table.ForeignKeyColumnsNames;

               StoreSpecials.Text = GetPageContent("Sales/Store Specials");
        }
        private string GetEntityTemplateVirtualPathWithCaching(MetaTable table, DataBoundControlMode mode, string uiHint) {
            long cacheKey = Misc.CombineHashCodes(table, mode, uiHint);

            return _factory.GetTemplatePath(cacheKey, delegate() {
                return GetEntityTemplateVirtualPath(table, mode, uiHint);
            });
        }
        private static bool AreEntitiesEqual(MetaTable table, object entity1, object entity2)
        {
            var pks1 = table.GetPrimaryKeyValues(entity1);
            var pks2 = table.GetPrimaryKeyValues(entity2);

            return pks1.SequenceEqual(pks2);
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------------------------
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);

               //GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
               //GridView1.RowCreated += new GridViewRowEventHandler(GridView1_RowCreated);
               GridDataSource.EntityTypeFilter = table.EntityType.Name;

               // HACKED TOGETHER FOR NOW
               if (User.Identity.IsAuthenticated)
               {
                    GridDataSource.WhereParameters.Add(new Parameter("OrganizationId", DbType.Guid, LoggedInUser.OrganizationId.ToString()));
               }
               else
               {
                    GridDataSource.WhereParameters.Add(new Parameter("OrganizationId", DbType.Guid, "0baae579-dbd8-488d-9e51-dd4dd6079e95"));
               }

               GridDataSource.OrderBy = "it.PublishAt desc";

               Master.FixedWidth = true;
               Master.FormTitle = table.DisplayName;
               IsPublic = true;

               //Master.FormTitle = "Professional Services";
               Master.FormDescription = "If you need help or would like to discuss a custom project please call us at +1-714-872-5920.";

               if (Roles.IsUserInRole("Administrators"))
                    AdminLinks.Visible = true;
        }
Ejemplo n.º 6
0
        // Methods
        public FieldGenerator( MetaTable table, Control dataBoundControl, DataBoundControlMode mode )
        {
            this._table = table;
            this._dataBoundControl = dataBoundControl;
            this._mode = mode;

            List<MetaColumn> columns = new List<MetaColumn>( _table.Columns );

            //упорядочить колонки в порядке следования в мета-классе.
            var metadataTypeAttribute = (MetadataTypeAttribute)Attribute.GetCustomAttribute( _table.EntityType, typeof( MetadataTypeAttribute ), false );
            if( metadataTypeAttribute != null )
            {
                int index = 0;
                foreach( var memberInfo in metadataTypeAttribute.MetadataClassType.GetMembers().Where( m => m.MemberType == MemberTypes.Field || m.MemberType == MemberTypes.Property ) )
                {
                    int pos = columns.FindIndex( c => c.Name == memberInfo.Name );
                    if( pos >= 0 )
                    {
                        MetaColumn column = columns[ pos ];
                        columns.RemoveAt( pos );
                        columns.Insert( index++, column );
                    }
                }
            }
            _columns = columns;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            this.table = DynamicDataRouteHandler.GetRequestMetaTable(this.Context);

            this.FormView1.SetMetaTable(this.table);
            this.DetailsDataSource.ContextTypeName = this.table.DataContextType.FullName;
        }
Ejemplo n.º 8
0
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
            GridDataSource.EntityTypeFilter = table.EntityType.Name;

            // Set the search data fields to all the string columns
            var searchExpression = (SearchExpression)GridQueryExtender.Expressions[1];
            searchExpression.DataFields = String.Join(",", table.Columns.Where(c => c.IsString).Select(c => c.Name));
            if (String.IsNullOrEmpty(searchExpression.DataFields))
            {
                // No string fields, remove the search elements
                SearchPanel.Visible = false;
                GridQueryExtender.Expressions.Remove(searchExpression);
            }

            // Disable various options if the table is readonly
            GridView1.ColumnsGenerator = new OrderedFieldGenerator(table);
            if (table.IsReadOnly)
            {
                GridView1.Columns[0].Visible = false;
                InsertHyperLink.Visible = false;
                GridView1.EnablePersistedSelection = false;
            }
        }
Ejemplo n.º 9
0
        protected void Page_Init(object sender, EventArgs e) {
            DynamicDataManager1.RegisterControl(DetailsView1);
            table = DetailsDataSource.GetTable();
            DynamicDataFutures.DisablePartialRenderingForUpload(this, table);

            DetailsView1.RowsGenerator = new AdvancedFieldGenerator(table, false);
        }
Ejemplo n.º 10
0
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
            GridDataSource.EntityTypeFilter = table.EntityType.Name;

        }
Ejemplo n.º 11
0
 protected void Page_Init(object sender, EventArgs e) {
     table = GridDataSource.GetTable();
     DynamicDataManager1.RegisterControl(GridView1, true /*setSelectionFromUrl*/);
     GridView1.EnablePersistedSelection();
     GridView1.ColumnsGenerator = new AdvancedFieldGenerator(table, true);
     DynamicDataFutures.RegisterListDefaults(GridDataSource, InsertHyperLink);
 }
        public static MethodCallExpression BuildSingleItemQuery(IQueryable query, MetaTable metaTable, string[] primaryKeyValues) {
            // Items.Where(row => row.ID == 1)
            var whereCall = BuildItemsQuery(query, metaTable, metaTable.PrimaryKeyColumns, primaryKeyValues);
            // Items.Where(row => row.ID == 1).Single()
            var singleCall = Expression.Call(typeof(Queryable), "Single", new Type[] { metaTable.EntityType }, whereCall);

            return singleCall;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            FormView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));

            DetailsDataSource.DomainServiceTypeName = table.DataContextType.AssemblyQualifiedName;
            DetailsDataSource.QueryName = table.GetSelectMethod();
        }
Ejemplo n.º 14
0
 protected void Page_Init(object sender, EventArgs e) {
     table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
     GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
     GridDataSource.EntityTypeName = table.EntityType.AssemblyQualifiedName;
     if (table.EntityType != table.RootEntityType) {
         GridQueryExtender.Expressions.Add(new OfTypeExpression(table.EntityType));
     }
 }
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            FormView1.SetMetaTable(table);

            DetailsDataSource.DomainServiceTypeName = table.DataContextType.AssemblyQualifiedName;
            DetailsDataSource.QueryName = table.GetSelectMethod();
            FormView1.DataKeyNames = table.PrimaryKeyColumns.Select(c => c.Name).ToArray();
        }
Ejemplo n.º 16
0
 protected void Page_Init(object sender, EventArgs e)
 {
     table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
     DetailsView1.SetMetaTable(table);
     DetailsDataSource.EntityTypeFilter = table.EntityType.Name;
     DetailsView1.RowsGenerator = new OrderedFieldGenerator(table);
     Title = table.DisplayName;
     DetailsDataSource.Include = table.ForeignKeyColumnsNames;
 }
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            table = linqDataSource.GetTable();

            if (!IsPostBack)
            {
                _errorPanel.Visible = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e) {
            table = GridDataSource.GetTable();
            Title = table.DisplayName;

            // Disable various options if the table is readonly
            if (table.IsReadOnly) {
                GridView1.Columns[0].Visible = false;
            }
        }
        /// <summary>
        /// Creates a new AdvancedFieldGenerator.
        /// </summary>
        /// <param name="table">The table this class generates fields for.</param>
        /// <param name="multiItemMode"><value>true</value> to indicate a multi-item control such as GridView, <value>false</value> for a single-item control such as DetailsView.</param>
        public AdvancedFieldGenerator(MetaTable table, bool multiItemMode) {
            if (table == null) {
                throw new ArgumentNullException("table");
            }

            _table = table;
            _containerType = multiItemMode ? ContainerType.List : ContainerType.Item;
            SkipList = new List<MetaColumn>();
        }
Ejemplo n.º 20
0
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            FormView1.SetMetaTable(table);
            DetailsDataSource.EntityTypeFilter = table.EntityType.Name;

            DetailsDataSource.ContextCreating += (o, args) =>
            {
                args.Context = (ObjectContext)table.CreateContext();
            };
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));

            GridDataSource.DomainServiceTypeName = table.DataContextType.AssemblyQualifiedName;
            GridDataSource.QueryName = table.GetSelectMethod();

            GridView1.ColumnsGenerator = new DefaultAutoFieldGenerator(table);
            GridView1.DataKeyNames = table.PrimaryKeyColumns.Select(c => c.Name).ToArray();
        }
 private static IEnumerable<MetaColumn> SortColumns(MetaTable table, IEnumerable<MetaColumn> columns)
 {
     string[] order;
     if (!SortOrders.TryGetValue(table.Name, out order))
     {
         order = new string[0];
     }
     return Enumerable.Concat(
         order.Select(s => columns.Single(c => String.Equals(c.Name, s))),
         columns.Where(c => !order.Contains(c.Name)));
 }
 public static MethodCallExpression BuildItemsQuery(IQueryable query, MetaTable metaTable, IList<MetaColumn> columns, string[] values) {
     // row
     var rowParam = Expression.Parameter(metaTable.EntityType, "row");
     // row.ID == 1
     var whereBody = BuildWhereBody(rowParam, columns, values);
     // row => row.ID == 1
     var whereLambda = Expression.Lambda(whereBody, rowParam);
     // Items.Where(row => row.ID == 1)
     var whereCall = Expression.Call(typeof(Queryable), "Where", new Type[] { metaTable.EntityType }, query.Expression, whereLambda);
     
     return whereCall;
 }
Ejemplo n.º 24
0
        protected void Page_Init(object sender, EventArgs e)
        {
            IsPublic = true;

               table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
               FormView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
               DetailsDataSource.EntityTypeFilter = table.EntityType.Name;

               Master.FormTitle = "Add new entry to " + table.DisplayName;

               DetailsDataSource.Inserted += new EventHandler<EntityDataSourceChangedEventArgs>(DetailsDataSource_Inserted);
        }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e) {
            table = GridDataSource.GetTable();
            Title = table.DisplayName;

            InsertHyperLink.NavigateUrl = table.GetActionPath(PageAction.Insert);

            // Disable various options if the table is readonly
            if (table.IsReadOnly) {
                GridView1.Columns.RemoveAt(0);
                InsertHyperLink.Visible = false;
            }
        }
        public virtual EntityTemplateUserControl CreateEntityTemplate(MetaTable table, DataBoundControlMode mode, string uiHint) {
            if (table == null) {
                throw new ArgumentNullException("table");
            }

            string entityTemplatePath = GetEntityTemplateVirtualPathWithCaching(table, mode, uiHint);
            if (entityTemplatePath == null) {
                return null;
            }

            return _templateInstantiator(entityTemplatePath);
        }
        private string GetPageVirtualPath(DynamicDataRoute route, MetaTable table, string action) {
            long cacheKey = Misc.CombineHashCodes(table, route.ViewName ?? action);

            Dictionary<long, string> virtualPathCache = GetVirtualPathCache();

            string virtualPath;
            if (!virtualPathCache.TryGetValue(cacheKey, out virtualPath)) {
                virtualPath = GetPageVirtualPathNoCache(route, table, action);
                lock (virtualPathCache) {
                    virtualPathCache[cacheKey] = virtualPath;
                }
            }
            return virtualPath;
        }
        /// <summary>
        /// Create a handler to process a Dynamic Data request
        /// </summary>
        /// <param name="route">The Route that was matched</param>
        /// <param name="table">The MetaTable found in the route</param>
        /// <param name="action">The Action found in the route</param>
        /// <returns></returns>
        public virtual IHttpHandler CreateHandler(DynamicDataRoute route, MetaTable table, string action) {
            // First, get the path to the page (could be custom, shared, or null)
            string virtualPath = GetPageVirtualPath(route, table, action);

            if (virtualPath != null) {
                // Gets called only for custom pages that we know exist or templates that may or may not
                // exist. This method will throw if virtualPath does not exist, which is fine for templates
                // but is not fine for custom pages.
                return CreateHandlerCallback(virtualPath);
            } else {
                // This should only occur in the event that scaffolding is disabled and the custom page
                // virtual path does not exist.
                return null;
            }
        }
Ejemplo n.º 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            table = GridDataSource.GetTable();

            Title = table.DisplayName;

            if (table.IsReadOnly)
            {
                GridView1.Columns[0].Visible = false;
            }

            if (!Page.IsPostBack)
            {
                ApplyStaticFilters();
                ApplySort();
            }
        }
Ejemplo n.º 30
0
 // SAMPLE META DATA:
 //[UIHint("FileUpload")]
 //[FileUpload(
 //    FileUrl = "~/files/{0}",
 //    FileTypes = new String[] { "pdf", "xls", "doc", "xps" },
 //    DisplayImageType = "png",
 //    DisableHyperlink = false,
 //    HyperlinkRoles = new String[] { "Admin", "Accounts" },
 //    DisplayImageUrl = "~/images/{0}")]
 //[ImageFormat(22, 0)]
 /// <summary>
 /// If the given table contains a column that has a UI Hint with the value "DbImage", finds the ScriptManager
 /// for the current page and disables partial rendering
 /// </summary>
 /// <param name="page"></param>
 /// <param name="table"></param>
 public static void DisablePartialRenderingForUpload(Page page, MetaTable table)
 {
     foreach (var column in table.Columns)
        {
             // TODO this depends on the name of the field template, need to fix
             if (String.Equals(column.UIHint, "DBImage", StringComparison.OrdinalIgnoreCase) &&
                 String.Equals(column.UIHint, "FileImage", StringComparison.OrdinalIgnoreCase) &&
                 String.Equals(column.UIHint, "FileUpload", StringComparison.OrdinalIgnoreCase))
             {
                  var sm = ScriptManager.GetCurrent(page);
                  if (sm != null)
                  {
                       sm.EnablePartialRendering = false;
                  }
                  break;
             }
        }
 }
Ejemplo n.º 31
0
        public void RegisterControl(Control control, bool setSelectionFromUrl)
        {
            // .NET doesn't check for null here, but since I don't like such code, we
            // will do the check and throw the same exception as .NET
            if (control == null)
            {
                throw new NullReferenceException();
            }

            if (!ControlIsValid(control))
            {
                throw new Exception("Controls of type " + control.GetType() + " are not supported.");
            }

            // http://forums.asp.net/p/1257004/2339034.aspx
            // http://forums.asp.net/p/1383908/2936065.aspx
            DataBoundControl dbc = control as DataBoundControl;

            if (dbc != null)
            {
                IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
                if (dds == null)
                {
                    return;
                }

                RegisterDataSource(dds);
                MetaTable table = dds.GetTable();
                if (table == null)
                {
                    return;
                }

                if (String.IsNullOrEmpty(dds.Where))
                {
                    dds.AutoGenerateWhereClause = true;
                }
                else
                {
                    dds.AutoGenerateWhereClause = false;
                }

                Type contextType = dds.ContextType;
                if (contextType == null)
                {
                    dds.ContextType = table.DataContextType;
                }

                string entityName = dds.EntitySetName;
                if (String.IsNullOrEmpty(entityName))
                {
                    dds.EntitySetName = table.DataContextPropertyName;
                }

                if (AutoLoadForeignKeys)
                {
                    var ldds = dds as LinqDataSource;
                    if (ldds != null)
                    {
                        ldds.LoadWithForeignKeys(table.EntityType);
                    }
                }

                var gv = control as GridView;
                if (gv != null)
                {
                    gv.ColumnsGenerator = new AutoFieldGenerator(table);
                    return;
                }

                var dv = control as DetailsView;
                if (dv != null)
                {
                    dv.RowsGenerator = new AutoFieldGenerator(table);
                    return;
                }
            }
        }
        /// <summary>
        /// See IWhereParametersProvider.GetWhereParameters
        /// </summary>
        public virtual IEnumerable <Parameter> GetWhereParameters(IDynamicDataSource dataSource)
        {
            Debug.Assert(dataSource != null);

            // Find the control that the ControlParameter uses
            Control control = Misc.FindControl((Control)dataSource, ControlId);

            if (control == null)
            {
                throw new InvalidOperationException(String.Format(
                                                        CultureInfo.CurrentCulture, DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlNotFound, ControlId));
            }

            // If the control is itself a parameter provider, delegate to it
            var whereParametersProvider = control as IWhereParametersProvider;

            if (whereParametersProvider != null)
            {
                return(whereParametersProvider.GetWhereParameters(dataSource));
            }

            IControlParameterTarget paramTarget = DynamicDataManager.GetControlParameterTarget(control);

            if (paramTarget == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  DynamicDataResources.DynamicControlParameter_DynamicDataSourceControlCannotBeUsedAsParent, ControlId));
            }

            string     columnName = Name;
            MetaColumn column     = null;
            MetaTable  table      = MetaTableHelper.GetTableWithFullFallback(dataSource, HttpContext.Current.ToWrapper());

            if (!String.IsNullOrEmpty(columnName))
            {
                column = table.GetColumn(columnName);
            }
            else
            {
                // There was no Name attribute telling us what field to filter, but maybe
                // the control given us data has that info
                column = paramTarget.FilteredColumn;
            }

            if (column == null)
            {
                // If there is no specific column, we're setting the primary key

                if (paramTarget.Table != table)
                {
                    throw new Exception(String.Format(CultureInfo.CurrentCulture,
                                                      DynamicDataResources.DynamicControlParameter_InvalidPK,
                                                      ControlId, paramTarget.Table, table.Name));
                }

                return(GetPrimaryKeyControlWhereParameters(control, paramTarget));
            }
            else if (column is MetaForeignKeyColumn)
            {
                return(GetForeignKeyControlWhereParameters(control, paramTarget, (MetaForeignKeyColumn)column));
            }
            return(GetPropertyControlWhereParameters(control, paramTarget, column));
        }
Ejemplo n.º 33
0
 public MetaChildrenColumn(MetaTable table, ColumnProvider entityMember)
     : base(table, entityMember)
 {
 }
Ejemplo n.º 34
0
        public void IsBinaryData()
        {
            MetaModel m = Utils.CommonInitialize();

            MetaTable  t  = m.Tables[TestDataContext.TableBazDataTypeDefaultTypes];
            MetaColumn mc = t.GetColumn("Char_Column");

            Assert.IsNotNull(mc, "#A1");
            Assert.AreEqual(false, mc.IsBinaryData, "#A2");

            mc = t.GetColumn("Byte_Column");
            Assert.IsNotNull(mc, "#A2");
            Assert.AreEqual(false, mc.IsBinaryData, "#A2-1");

            mc = t.GetColumn("Int_Column");
            Assert.IsNotNull(mc, "#A3");
            Assert.AreEqual(false, mc.IsBinaryData, "#A3-1");

            mc = t.GetColumn("Long_Column");
            Assert.IsNotNull(mc, "#A4");
            Assert.AreEqual(false, mc.IsBinaryData, "#A4-1");

            mc = t.GetColumn("Bool_Column");
            Assert.IsNotNull(mc, "#A5");
            Assert.AreEqual(false, mc.IsBinaryData, "#A5-1");

            mc = t.GetColumn("String_Column");
            Assert.IsNotNull(mc, "#A6");
            Assert.AreEqual(false, mc.IsBinaryData, "#A6-1");

            mc = t.GetColumn("DateTime_Column");
            Assert.IsNotNull(mc, "#A7");
            Assert.AreEqual(false, mc.IsBinaryData, "#A7-1");

            mc = t.GetColumn("FooEmpty_Column");
            Assert.IsNotNull(mc, "#A8");
            Assert.AreEqual(false, mc.IsBinaryData, "#A8-1");

            mc = t.GetColumn("Object_Column");
            Assert.IsNotNull(mc, "#A9");
            Assert.AreEqual(false, mc.IsBinaryData, "#A9-1");

            mc = t.GetColumn("ByteArray_Column");
            Assert.IsNotNull(mc, "#A10");
            Assert.AreEqual(true, mc.IsBinaryData, "#A10-1");

            mc = t.GetColumn("IntArray_Column");
            Assert.IsNotNull(mc, "#A11");
            Assert.AreEqual(false, mc.IsBinaryData, "#A11-1");

            mc = t.GetColumn("StringArray_Column");
            Assert.IsNotNull(mc, "#A12");
            Assert.AreEqual(false, mc.IsBinaryData, "#A12-1");

            mc = t.GetColumn("ObjectArray_Column");
            Assert.IsNotNull(mc, "#A13");
            Assert.AreEqual(false, mc.IsBinaryData, "#A13-1");

            mc = t.GetColumn("StringList_Column");
            Assert.IsNotNull(mc, "#A14");
            Assert.AreEqual(false, mc.IsBinaryData, "#A14-1");

            mc = t.GetColumn("Dictionary_Column");
            Assert.IsNotNull(mc, "#A15");
            Assert.AreEqual(false, mc.IsBinaryData, "#A15-1");

            mc = t.GetColumn("ICollection_Column");
            Assert.IsNotNull(mc, "#A16");
            Assert.AreEqual(false, mc.IsBinaryData, "#A16-1");

            mc = t.GetColumn("IEnumerable_Column");
            Assert.IsNotNull(mc, "#A17");
            Assert.AreEqual(false, mc.IsBinaryData, "#A17-1");

            mc = t.GetColumn("ICollectionByte_Column");
            Assert.IsNotNull(mc, "#A18");
            Assert.AreEqual(false, mc.IsBinaryData, "#A18-1");

            mc = t.GetColumn("IEnumerableByte_Column");
            Assert.IsNotNull(mc, "#A19");
            Assert.AreEqual(false, mc.IsBinaryData, "#A19-1");

            mc = t.GetColumn("ByteMultiArray_Column");
            Assert.IsNotNull(mc, "#A20");
            Assert.AreEqual(false, mc.IsBinaryData, "#A20-1");

            mc = t.GetColumn("BoolArray_Column");
            Assert.IsNotNull(mc, "#A21");
            Assert.AreEqual(false, mc.IsBinaryData, "#A21-1");
        }
Ejemplo n.º 35
0
        public void Scaffold()
        {
            //
            // ScaffoldAllTables=true is in effect for this model
            //
            MetaModel m = Utils.CommonInitialize();

            MetaTable  t  = m.Tables[TestDataContext.TableBazColumnAttributes];
            MetaColumn mc = t.GetColumn("NoScaffoldColumn");

            Assert.IsNotNull(mc, "#1");
            Assert.AreEqual(false, mc.Scaffold, "#1-1");

            mc = t.GetColumn("ScaffoldAttributeColumn");
            Assert.IsNotNull(mc, "#2");
            Assert.AreEqual(true, mc.Scaffold, "#2-1");

            mc = t.GetColumn("ColumnNoAttributes");
            Assert.IsNotNull(mc, "#3");
            Assert.AreEqual(true, mc.Scaffold, "#3-1");

            // No attribute cases
            mc = t.GetColumn("UIHintColumn");
            Assert.IsNotNull(mc, "#4");
            Assert.AreEqual(true, mc.Scaffold, "#4-1");

            t  = m.Tables[TestDataContext.TableFooNoScaffold];
            mc = t.GetColumn("Column1");
            Assert.IsNotNull(mc, "#5");
            Assert.AreEqual(true, mc.Scaffold, "#5-1");

            t  = m.Tables[TestDataContext.TableBaz];
            mc = t.GetColumn("GeneratedColumn1");
            Assert.IsNotNull(mc, "#6");
            Assert.AreEqual(false, mc.Scaffold, "#6-1");

            mc = t.GetColumn("GeneratedColumn2");
            Assert.IsNotNull(mc, "#7");
            Assert.AreEqual(true, mc.Scaffold, "#7-1");

            mc = t.GetColumn("CustomPropertyColumn1");
            Assert.IsNotNull(mc, "#8");
            Assert.AreEqual(false, mc.Scaffold, "#8-1");

            mc = t.GetColumn("CustomPropertyColumn2");
            Assert.IsNotNull(mc, "#9");
            Assert.AreEqual(true, mc.Scaffold, "#9-1");

            t  = m.Tables[TestDataContext.TableAssociatedFoo];
            mc = t.GetColumn("ForeignKeyColumn1");
            Assert.IsNotNull(mc, "#10");
            Assert.AreEqual(true, mc.IsForeignKeyComponent, "#10-1");
            Assert.AreEqual(true, mc.Scaffold, "#11-2");

            m  = MetaModel.GetModel(dynamicModelProviderNoScaffold.ContextType);
            t  = m.Tables[TestDataContext2.TableFooBarNoScaffold];
            mc = t.GetColumn("Column1");
            Assert.IsNotNull(mc, "#12");
            Assert.AreEqual(true, mc.Scaffold, "#12-1");

            mc = t.GetColumn("CustomPropertyColumn1");
            Assert.IsNotNull(mc, "#13");
            Assert.AreEqual(false, mc.Scaffold, "#13-1");

            mc = t.GetColumn("CustomPropertyColumn2");
            Assert.IsNotNull(mc, "#14");
            Assert.AreEqual(true, mc.Scaffold, "#14-1");

            mc = t.GetColumn("GeneratedColumn1");
            Assert.IsNotNull(mc, "#15");
            Assert.AreEqual(false, mc.Scaffold, "#15-1");

            mc = t.GetColumn("GeneratedColumn2");
            Assert.IsNotNull(mc, "#16");
            Assert.AreEqual(true, mc.Scaffold, "#16-1");

            mc = t.GetColumn("ForeignKeyColumn1");
            Assert.IsNotNull(mc, "#17");
            Assert.AreEqual(true, mc.IsForeignKeyComponent, "#17-1");
            Assert.AreEqual(true, mc.Scaffold, "#17-2");
        }
Ejemplo n.º 36
0
        public void TypeCodeTest()
        {
            MetaModel m = Utils.CommonInitialize();

            MetaTable  t  = m.Tables[TestDataContext.TableBazDataTypeDefaultTypes];
            MetaColumn mc = t.GetColumn("Char_Column");

            Assert.IsNotNull(mc, "#A1");
            Assert.AreEqual(typeof(char), mc.ColumnType, "#A1-1");
            Assert.AreEqual(TypeCode.Object, mc.TypeCode, "#A1-2");

            mc = t.GetColumn("String_Column");
            Assert.IsNotNull(mc, "#B1");
            Assert.AreEqual(typeof(string), mc.ColumnType, "#B1-1");
            Assert.AreEqual(TypeCode.String, mc.TypeCode, "#B1-2");

            mc = t.GetColumn("Byte_Column");
            Assert.IsNotNull(mc, "#C1");
            Assert.AreEqual(typeof(byte), mc.ColumnType, "#C1-1");
            Assert.AreEqual(TypeCode.Byte, mc.TypeCode, "#C1-2");

            mc = t.GetColumn("SByte_Column");
            Assert.IsNotNull(mc, "#D1");
            Assert.AreEqual(typeof(sbyte), mc.ColumnType, "#d1-1");
            Assert.AreEqual(TypeCode.Object, mc.TypeCode, "#D1-2");

            mc = t.GetColumn("Int_Column");
            Assert.IsNotNull(mc, "#E1");
            Assert.AreEqual(typeof(int), mc.ColumnType, "#E1-1");
            Assert.AreEqual(TypeCode.Int32, mc.TypeCode, "#E1-2");

            mc = t.GetColumn("UInt_Column");
            Assert.IsNotNull(mc, "#F1");
            Assert.AreEqual(typeof(uint), mc.ColumnType, "#F1-1");
            Assert.AreEqual(TypeCode.Object, mc.TypeCode, "#F1-2");

            mc = t.GetColumn("Long_Column");
            Assert.IsNotNull(mc, "#G1");
            Assert.AreEqual(typeof(long), mc.ColumnType, "#G1-1");
            Assert.AreEqual(TypeCode.Int64, mc.TypeCode, "#G1-2");

            mc = t.GetColumn("Float_Column");
            Assert.IsNotNull(mc, "#H1");
            Assert.AreEqual(typeof(float), mc.ColumnType, "#H1-1");
            Assert.AreEqual(TypeCode.Single, mc.TypeCode, "#H1-2");

            mc = t.GetColumn("Double_Column");
            Assert.IsNotNull(mc, "#I1");
            Assert.AreEqual(typeof(double), mc.ColumnType, "#I1-1");
            Assert.AreEqual(TypeCode.Double, mc.TypeCode, "#I1-2");

            mc = t.GetColumn("Decimal_Column");
            Assert.IsNotNull(mc, "#J1");
            Assert.AreEqual(typeof(decimal), mc.ColumnType, "#J1-1");
            Assert.AreEqual(TypeCode.Decimal, mc.TypeCode, "#J1-2");

            mc = t.GetColumn("StringArray_Column");
            Assert.IsNotNull(mc, "#K1");
            Assert.AreEqual(typeof(string[]), mc.ColumnType, "#K1-1");
            Assert.AreEqual(TypeCode.Object, mc.TypeCode, "#K1-2");
        }
Ejemplo n.º 37
0
        public void DataTypeAttribute()
        {
            MetaModel m = Utils.CommonInitialize();

            MetaTable  t  = m.Tables[TestDataContext.TableBazColumnAttributes];
            MetaColumn mc = t.GetColumn("ColumnNoAttributes");

            Assert.IsNotNull(mc, "#A1");
            Assert.IsNotNull(mc.DataTypeAttribute, "#A1-1");

            mc = t.GetColumn("ColumnWithDataType");
            Assert.IsNotNull(mc, "#A2");
            Assert.IsNotNull(mc.DataTypeAttribute, "#A2-1");
            Assert.AreEqual(DataType.EmailAddress, mc.DataTypeAttribute.DataType, "#A2-2");

            t  = m.Tables[TestDataContext.TableFooWithMetadataType];
            mc = t.GetColumn("Column2");
            Assert.IsNotNull(mc, "#C1");
            Assert.IsNotNull(mc.DataTypeAttribute, "#C1-1");
            Assert.AreEqual(DataType.Time, mc.DataTypeAttribute.DataType, "#C1-2");

            mc = t.GetColumn("Column3");
            Assert.IsNotNull(mc, "#C2");
            Assert.IsNotNull(mc.DataTypeAttribute, "#C2-1");
            Assert.AreEqual(DataType.Currency, mc.DataTypeAttribute.DataType, "#C2-2");

            // Check default types for columns not decorated with the attribute
            t  = m.Tables[TestDataContext.TableBazDataTypeDefaultTypes];
            mc = t.GetColumn("Char_Column");
            Assert.IsNotNull(mc, "#D1");
            Assert.IsNull(mc.DataTypeAttribute, "#D1-1");

            mc = t.GetColumn("Byte_Column");
            Assert.IsNotNull(mc, "#D2");
            Assert.IsNull(mc.DataTypeAttribute, "#D2-1");

            mc = t.GetColumn("Int_Column");
            Assert.IsNotNull(mc, "#D3");
            Assert.IsNull(mc.DataTypeAttribute, "#D3-1");

            mc = t.GetColumn("Long_Column");
            Assert.IsNotNull(mc, "#D4");
            Assert.IsNull(mc.DataTypeAttribute, "#D4-1");

            mc = t.GetColumn("Bool_Column");
            Assert.IsNotNull(mc, "#D5");
            Assert.IsNull(mc.DataTypeAttribute, "#D5-1");

            mc = t.GetColumn("String_Column");
            Assert.IsNotNull(mc, "#D6");
            Assert.IsNotNull(mc.DataTypeAttribute, "#D6-1");
            Assert.AreEqual(DataType.Text, mc.DataTypeAttribute.DataType, "#D6-2");

            mc = t.GetColumn("DateTime_Column");
            Assert.IsNotNull(mc, "#D7");
            Assert.IsNull(mc.DataTypeAttribute, "#D7-1");

            mc = t.GetColumn("FooEmpty_Column");
            Assert.IsNotNull(mc, "#D7");
            Assert.IsNull(mc.DataTypeAttribute, "#D7-1");
        }
Ejemplo n.º 38
0
 public AutoFieldGenerator(MetaTable table)
 {
     this.table = table;
 }