當前位置: 首頁>>代碼示例>>C#>>正文


C# Proxy.query方法代碼示例

本文整理匯總了C#中System.Proxy.query方法的典型用法代碼示例。如果您正苦於以下問題:C# Proxy.query方法的具體用法?C# Proxy.query怎麽用?C# Proxy.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Proxy的用法示例。


在下文中一共展示了Proxy.query方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateObjectDefinition

        protected DataObject CreateObjectDefinition(Proxy proxy, ClassObject classObject)
        {
            if (classObject.Ids == null || classObject.Ids.Count == 0)
              {
            return null;
              }

              string metadataQuery = string.Empty;

              if (classObject.ObjectType == ObjectType.Tag)
              {
            metadataQuery = string.Format(TAG_METADATA_SQL, (int)ObjectType.Tag);
              }
              else if (classObject.ObjectType == ObjectType.Document)
              {
            metadataQuery = string.Format(DOCUMENT_METADATA_SQL, (int)ObjectType.Document);
              }
              else
              {
            throw new Exception(string.Format("Object type [{0}] not supported.", classObject.ObjectType));
              }

              int status = 0;
              string result = proxy.query(metadataQuery, ref status);
              XmlDocument resultXml = new XmlDocument();
              resultXml.LoadXml(result);

              string type = Enum.GetName(typeof(ObjectType), classObject.ObjectType);
              DataObject objDef = new DataObject();
              objDef.objectNamespace = type;
              objDef.objectName = classObject.Name + "(" + type + ")";
              objDef.tableName = string.Join("_", classObject.Ids.ToArray());
              objDef.keyDelimeter = _keyDelimiter;

              Configuration config = GetConfiguration(objDef);
              if (config == null)
            return null;

              Map codeMap = config.Mappings.ToList<Map>().Find(x => x.Destination == (int)Destination.Code);
              if (codeMap == null)
              {
            throw new Exception("No mapping configured for key property.");
              }

              objDef.keyProperties = new List<KeyProperty>()
              {
            new KeyProperty() { keyPropertyName = codeMap.Column }
              };

              foreach (XmlNode attrNode in resultXml.DocumentElement.ChildNodes)
              {
            DataProperty dataProp = new DataProperty();
            dataProp.columnName = attrNode.SelectSingleNode("char_name").InnerText;

            string propertyName = Utilities.ToPropertyName(dataProp.columnName);
            if (objDef.dataProperties.Find(x => x.propertyName == propertyName) != null)
              continue;

            dataProp.propertyName = propertyName;
            dataProp.dataType = Utilities.ToCSharpType(attrNode.SelectSingleNode("char_data_type").InnerText);
            dataProp.dataLength = Int32.Parse(attrNode.SelectSingleNode("char_length").InnerText);

            if (attrNode.SelectSingleNode("is_system_char").InnerText == "1")
            {
              dataProp.columnName += Utilities.SYSTEM_ATTRIBUTE_TOKEN;
            }
            else
            {
              dataProp.columnName += Utilities.USER_ATTRIBUTE_TOKEN;
            }

            objDef.dataProperties.Add(dataProp);
              }

              // add related properties
              foreach (Map m in config.Mappings.Where(x => x.Destination == (int)Destination.Relationship).Select(m => m))
              {
            DataProperty dataProp = new DataProperty();
            string propertyName = Utilities.ToPropertyName(m.Column);
            DataProperty checkProp = objDef.dataProperties.Find(x => x.propertyName == propertyName);

            if (checkProp != null)  // property already exists, update its column name
            {
              checkProp.columnName = m.Column + Utilities.RELATED_ATTRIBUTE_TOKEN;
            }
            else
            {
              dataProp.columnName = m.Column + Utilities.RELATED_ATTRIBUTE_TOKEN;
              dataProp.propertyName = propertyName;
              dataProp.dataType = DataType.String;
              objDef.dataProperties.Add(dataProp);
            }
              }

              // add other properties
              foreach (Map m in config.Mappings.Where(x => x.Destination != (int)Destination.Relationship &&
            x.Destination != (int)Destination.Attribute && x.Destination != (int)Destination.None).Select(m => m))
              {
            DataProperty dataProp = new DataProperty();
            string propertyName = Utilities.ToPropertyName(m.Column);
//.........這裏部分代碼省略.........
開發者ID:Vidisha,項目名稱:eb,代碼行數:101,代碼來源:ebDataLayer.cs


注:本文中的System.Proxy.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。