Ejemplo n.º 1
0
        private static void LocalizeRelatedField(string fieldName, GridColumn column, Entity entity)
        {
            var fieldSegments = fieldName.Split('.');

            if (fieldSegments.Length == 2)
            {
                var mainPropertyName   = fieldSegments[0];
                var subPropertyName    = fieldSegments[1];
                var mainLocalizedLabel = GetLocalizedLabel(entity, mainPropertyName + "Id");

                var entityType   = DynamicDataServiceContext.GetTypeDefinition(entity.PhysicalName);
                var propertyType =
                    entityType.NavigationProperties().Single(p => p.Name == mainPropertyName).ToEntityType();

                var subPropertyEntity =
                    MetadataProvider.Instance.EntiyMetadata.First(e => e.PhysicalName == propertyType.Name);
                var subLocalizedLabel = GetLocalizedLabel(subPropertyEntity, subPropertyName);
                var columnMetadata    = subPropertyEntity.Attributes.FirstOrDefault(a => a.PhysicalName == subPropertyName);
                column.Caption = string.Format(Resources.ColumnCaptionFormat, mainLocalizedLabel ?? string.Empty, subLocalizedLabel);
                if (columnMetadata != null && columnMetadata.OptionSetId != null)
                {
                    var lookUpEdit = new RepositoryItemLookUpEdit();
                    lookUpEdit.BindPickList(subPropertyEntity, subPropertyName);
                    column.ColumnEdit = lookUpEdit;
                }
                else if (columnMetadata != null && columnMetadata.LogicalName == "MultipleLineText")
                {
                    var memoEdit = new RepositoryItemMemoEdit();
                    column.ColumnEdit = memoEdit;
                }
            }
        }
        void DynamicWcfInstantFeedbackSourceGetSource(object sender, GetSourceEventArgs e)
        {
            var entityType       = DynamicDataServiceContext.GetTypeDefinition(_entityName);
            var primaryFieldName = entityType.Key().First().Name;

            e.Query         = _context.CreateObjectQuery(_entityName, null, null);
            e.KeyExpression = primaryFieldName;
        }
Ejemplo n.º 3
0
        public void Init(Guid entityId, GridView gridView)
        {
            _gridView = gridView;
            var           entityMeta      = MetadataProvider.Instance.EntiyMetadata.Single(e => e.EntityId == entityId);
            var           entityType      = DynamicDataServiceContext.GetTypeDefinition(entityMeta.PhysicalName);
            List <string> allFields       = PopuldateFieldList(entityType).ToList();
            List <string> selectedFields  = gridView.Columns.Cast <GridColumn>().Select(c => c.FieldName).ToList();
            List <string> availableFields = allFields.Except(selectedFields).ToList();

            fieldsListBox.DataSource  = availableFields;
            columnsListBox.DataSource = selectedFields;
        }
        private void InitPickUp(string filterEntityName)
        {
            if (string.IsNullOrEmpty(filterEntityName))
            {
                panelControl1.Visible = false; return;
            }
            var entityType = DynamicDataServiceContext.GetTypeDefinition(filterEntityName);

            _filterKeyName = entityType.Key().First().Name;
            this.lookUpEdit1.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.LookUpBindingSource, _filterKeyName, true));
            BindLookUpData(_filterKeyName, _layoutEntityName);
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn(_filterKeyName));
            DataRow row = dt.NewRow();

            row[_filterKeyName] = Guid.Empty;
            dt.Rows.Add(row);
            LookUpBindingSource.DataSource = dt;
        }