Esempio n. 1
0
        public void MappingDocSeriliazationTest()
        {
            MappingDocument mapDoc     = new MappingDocument();
            MappingElement  mapeElColl = new MappingElement();

            mapeElColl.ClassName      = "Class1";
            mapeElColl.TableName      = "Table1";
            mapeElColl.PrimaryKeyName = "Id";

            MappingRule mapEl = new MappingRule();

            mapEl.ColumnName   = "column1";
            mapEl.FieldName    = "field1";
            mapEl.DefaultValue = "somevalue";

            mapeElColl.Add(mapEl);

            mapDoc.Add(mapeElColl);

            string xml = MappingDocument.GetXml(mapDoc);

            MappingDocument loadedDoc = MappingDocument.LoadFromXml(xml);

            string xml2 = MappingDocument.GetXml(loadedDoc);

            if (xml != xml2)
            {
                throw new AssertFailedException();
            }
        }
        /// <summary>
        /// Initializes the mapping document.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void InitializeMappingDocument(BusinessContext context)
        {
            InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request);

            MetaClass           metaClass     = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
            List <PrimaryKeyId> primaryKeyIds = new List <PrimaryKeyId>();

            // Create Default Mapping
            MappingDocument retVal = new MappingDocument();

            DataTable dataTable = request.Data.Tables[request.TableIndex];

            MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name);

            retVal.Add(mapping);

            MappingElementBuilder builder = new MappingElementBuilder(retVal);

            //Call creation mapping document by saved patterns
            DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder);

            // Write Response
            InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse();

            response.MappingDocument = retVal;

            context.SetResponse(response);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the mapping document.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void InitializeMappingDocument(BusinessContext context)
        {
            InitializeMappingDocumentRequest request = ((InitializeMappingDocumentRequest)context.Request);

            MetaClass metaClass = DataContext.Current.GetMetaClass(context.GetTargetMetaClassName());
            List<PrimaryKeyId> primaryKeyIds = new List<PrimaryKeyId>();

            // Create Default Mapping
            MappingDocument retVal = new MappingDocument();

            DataTable dataTable = request.Data.Tables[request.TableIndex];

            MappingElement mapping = new MappingElement(dataTable.TableName, metaClass.Name);
            retVal.Add(mapping);

            MappingElementBuilder builder = new MappingElementBuilder(retVal);

            //Call creation mapping document by saved patterns
            DefaultMappingHelper.CreateMapingByPatternComparision(dataTable, metaClass, builder);

            // Write Response
            InitializeMappingDocumentResponse response = new InitializeMappingDocumentResponse();
            response.MappingDocument = retVal;

            context.SetResponse(response);
        }