Ejemplo n.º 1
0
 public virtual object CreateResult(Net.Vpc.Upa.Impl.Persistence.Result.ResultColumn[] row, Net.Vpc.Upa.Persistence.ResultMetaData metadata)
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> fields = metadata.GetFields();
     Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData d = (Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData)metadata;
     string[] bindings = (string[])Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(d.GetProperties(), CACHE_KEY);
     if (bindings == null)
     {
         bindings = new string[(fields).Count];
         for (int i = 0; i < (fields).Count; i++)
         {
             Net.Vpc.Upa.Persistence.ResultField field = fields[i];
             Net.Vpc.Upa.Expressions.Expression  ss    = field.GetExpression();
             string binding = ss == null ? "null" : ss.ToString();
             bindings[i] = binding;
         }
         d.GetProperties()[CACHE_KEY] = bindings;
     }
     if ((fields).Count == 1)
     {
         string binding = bindings[0];
         return(row[0].GetValue());
     }
     else
     {
         object[] allRet = new object[(fields).Count];
         for (int i = 0; i < allRet.Length; i++)
         {
             allRet[i] = row[i].GetValue();
         }
         return(allRet);
     }
 }
 public virtual object CreateResult(Net.Vpc.Upa.Impl.Persistence.Result.ResultColumn[] row, Net.Vpc.Upa.Persistence.ResultMetaData metadata)
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> fields = metadata.GetFields();
     Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData d = (Net.Vpc.Upa.Impl.Persistence.DefaultResultMetaData)metadata;
     string[][] preferredNameAndBinding = (string[][])Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(d.GetProperties(), CACHE_KEY);
     if (preferredNameAndBinding == null)
     {
         preferredNameAndBinding = (string[][])Net.Vpc.Upa.Impl.FwkConvertUtils.CreateMultiArray(typeof(string), (fields).Count, 2);
         for (int i = 0; i < (fields).Count; i++)
         {
             Net.Vpc.Upa.Persistence.ResultField field = fields[i];
             Net.Vpc.Upa.Expressions.Expression  ss    = field.GetExpression();
             string binding       = ss == null ? "null" : ss.ToString();
             string preferredName = binding;
             if (preferredName.IndexOf('.') >= 0)
             {
                 preferredName = preferredName.Substring(preferredName.LastIndexOf('.') + 1);
             }
             string alias = field.GetAlias();
             if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(alias))
             {
                 preferredName = alias;
             }
             preferredNameAndBinding[i][0] = preferredName;
             preferredNameAndBinding[i][1] = binding;
         }
         d.GetProperties()[CACHE_KEY] = preferredNameAndBinding;
     }
     if ((fields).Count == 1 && row[0].GetValue() is Net.Vpc.Upa.Record)
     {
         return(row[0].GetValue());
     }
     Net.Vpc.Upa.Record r = new Net.Vpc.Upa.Impl.DefaultRecord();
     for (int i = 0; i < (fields).Count; i++)
     {
         string preferredName = preferredNameAndBinding[i][0];
         r.SetObject(preferredName, row[i].GetValue());
     }
     return(r);
 }