Exemplo n.º 1
0
        private void LoadObjectParameters()
        {
            for (int i = 0; i < columnManagers.Count; i++)
            {
                for (int j = 0; j < columnManagers [i].Count; j++)
                {
                    DbColumnManager manager = columnManagers [i] [j];
                    if (skippedFields.Contains(manager.DbField.StrongField))
                    {
                        continue;
                    }

                    string paramName = fTrans.GetParameterName(manager.DbField);
                    int    ind       = parameters.FindIndex(p => fTrans.GetParameterName(p.ParameterName) == paramName);
                    if (ind < 0)
                    {
                        parameters.Add(GetParameter(paramName, manager, objects [i]));
                    }
                    else
                    {
                        string altParamName = fTrans.GetAlternativeParameterName(manager.DbField);
                        ind = parameters.FindIndex(p => fTrans.GetParameterName(p.ParameterName) == altParamName);
                        DbParam par = GetParameter(altParamName, manager, objects [i]);
                        if (ind < 0)
                        {
                            parameters.Add(par);
                        }
                        else
                        {
                            parameters [ind] = par;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void SetObjectValue(DataField field, object value)
        {
            for (int i = 0; i < columnManagers.Count; i++)
            {
                for (int j = 0; j < columnManagers [i].Count; j++)
                {
                    DbColumnManager manager = columnManagers [i] [j];
                    if (field != manager.DbField)
                    {
                        continue;
                    }

                    Type   targetType  = Nullable.GetUnderlyingType(manager.MemberType) ?? manager.MemberType;
                    object targetValue = value == null ? null : Convert.ChangeType(value, targetType);

                    manager.SetValue(objects [i], targetValue);
                    return;
                }
            }
        }
Exemplo n.º 3
0
 protected virtual DbParam GetParameter(string paramName, DbColumnManager manager, object obj)
 {
     return(new DbParam(paramName, manager.GetValue(obj, true)));
 }