Esempio n. 1
0
        private IEnumerable Execute(BuiltQuery builtQuery)
        {
            if (EntityHelpers.IsConstant(builtQuery.EntityType))
            {
                var constantWrapType = builtQuery.EntityType.BaseType;
                if (constantWrapType == null)
                {
                    throw new InvalidOperationException("assertion failure");
                }
                var constantWrap = (Constant)FormatterServices.GetUninitializedObject(builtQuery.EntityType);
                var constants    = ComHelpers.GetProperty(globalContext.ComObject(), "Константы");
                var constant     = ComHelpers.GetProperty(constants, builtQuery.EntityType.Name);
                var value        = ComHelpers.Invoke(constant, "Получить");
                constantWrap.ЗначениеНетипизированное = comObjectMapper.MapFrom1C(value,
                                                                                  constantWrapType.GetGenericArguments()[0]);
                yield return(constantWrap);

                yield break;
            }
            var queryText  = builtQuery.QueryText;
            var parameters = builtQuery.Parameters;

            parametersConverter.ConvertParametersTo1C(parameters);
            var hasReference = ConfigurationName.Get(builtQuery.EntityType).HasReference;
            var queryResult  = globalContext.Execute(queryText, parameters);

            if (hasReference || builtQuery.Projection != null)
            {
                var projection = builtQuery.Projection != null
                    ? ProjectionMapperFactory.GetMapper(builtQuery.Projection, comObjectMapper)
                    : null;

                var selection = queryResult.Select();
                while (selection.Next())
                {
                    if (projection != null)
                    {
                        yield return(projection(selection.ComObject));
                    }
                    else if (builtQuery.IsCount)
                    {
                        yield return(comObjectMapper.MapFrom1C(selection["src_Count"], typeof(int)));
                    }
                    else
                    {
                        yield return(comObjectMapper.MapFrom1C(selection["Ссылка"], builtQuery.EntityType));
                    }
                }
            }
            else
            {
                var valueTable = queryResult.Unload();
                foreach (var r in valueTable)
                {
                    yield return(comObjectMapper.MapFrom1C(r.ComObject(), builtQuery.EntityType));
                }
            }
        }
Esempio n. 2
0
 public object MapGuidTo1C(Guid value)
 {
     return(ComHelpers.Invoke(globalContext.ComObject(),
                              "NewObject", "УникальныйИдентификатор", value.ToString()));
 }
Esempio n. 3
0
 public ComObjectMapper(MappingSource mappingSource, GlobalContext globalContext)
 {
     this.mappingSource = mappingSource;
     this.globalContext = globalContext;
     enumerations       = ComHelpers.GetProperty(globalContext.ComObject(), "Перечисления");
 }