internal static bool TryRewrite(DbQueryCommandTree tree, Span span, MergeOption mergeOption, AliasGenerator aliasGenerator, out DbExpression newQuery, out SpanIndex spanInfo)
        {
            newQuery = null;
            spanInfo = null;

            ObjectSpanRewriter rewriter = null;
            bool requiresRelationshipSpan = Span.RequiresRelationshipSpan(mergeOption);

            // Potentially perform a rewrite for span.
            // Note that the public 'Span' property is NOT used to retrieve the Span instance
            // since this forces creation of a Span object that may not be required.
            if (span != null && span.SpanList.Count > 0)
            {
                rewriter = new ObjectFullSpanRewriter(tree, tree.Query, span, aliasGenerator);
            }
            else if (requiresRelationshipSpan)
            {
                rewriter = new ObjectSpanRewriter(tree, tree.Query, aliasGenerator);
            }

            if (rewriter != null)
            {
                rewriter.RelationshipSpan = requiresRelationshipSpan;
                newQuery = rewriter.RewriteQuery();
                if (newQuery != null)
                {
                    Debug.Assert(rewriter.SpanIndex != null || tree.Query.ResultType.EdmEquals(newQuery.ResultType), "Query was rewritten for Span but no SpanIndex was created?");
                    spanInfo = rewriter.SpanIndex;
                }
            }

            return (spanInfo != null);
        }
        protected XrmServiceContext CreateXrmServiceContext(MergeOption? mergeOption = null)
        {
            //string organizationUri = ConfigurationManager.AppSettings["CRM_OrganisationUri"];

            string organizationUri = "https://existornest2.api.crm4.dynamics.com/XRMServices/2011/Organization.svc";

            IServiceManagement<IOrganizationService> OrganizationServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUri));
            AuthenticationProviderType OrgAuthType = OrganizationServiceManagement.AuthenticationType;
            AuthenticationCredentials authCredentials = GetCredentials(OrgAuthType);
            AuthenticationCredentials tokenCredentials = OrganizationServiceManagement.Authenticate(authCredentials);
            OrganizationServiceProxy organizationProxy = null;
            SecurityTokenResponse responseToken = tokenCredentials.SecurityTokenResponse;

            if (ConfigurationManager.AppSettings["CRM_AuthenticationType"] == "ActiveDirectory")
            {
                using (organizationProxy = new OrganizationServiceProxy(OrganizationServiceManagement, authCredentials.ClientCredentials))
                {
                    organizationProxy.EnableProxyTypes();
                }
            }
            else
            {
                using (organizationProxy = new OrganizationServiceProxy(OrganizationServiceManagement, responseToken))
                {
                    organizationProxy.EnableProxyTypes();
                }
            }

            IOrganizationService service = (IOrganizationService)organizationProxy;

            var context = new XrmServiceContext(service);
            if (context != null && mergeOption != null) context.MergeOption = mergeOption.Value;
            return context;
        }
            private void Calls_collection_override_passing_in_null(MergeOption mergeOption)
            {
                var entityCollectionMock = MockHelper.CreateMockEntityCollection<object>(null);

                int timesLoadCalled = 0;
                entityCollectionMock.Setup(m => m.Load(It.IsAny<List<IEntityWrapper>>(), It.IsAny<MergeOption>()))
                    .Callback((IEnumerable<object> actualCollection, MergeOption actualMergeOption) =>
                    {
                        timesLoadCalled++;
                        Assert.Equal(null, actualCollection);
                        Assert.Equal(mergeOption, actualMergeOption);
                    });

                int timesCheckOwnerNullCalled = 0;
                entityCollectionMock.Setup(m => m.CheckOwnerNull())
                    .Callback(() =>
                    {
                        timesCheckOwnerNullCalled++;
                    });

                entityCollectionMock.Object.Load(mergeOption);

                entityCollectionMock.Verify(m => m.Load(It.IsAny<List<IEntityWrapper>>(), It.IsAny<MergeOption>()));

                Assert.True(1 == timesLoadCalled, "Expected Load to be called once for MergeOption." + mergeOption);
                Assert.True(1 == timesCheckOwnerNullCalled, "Expected CheckOwnerNull to be called once for MergeOption." + mergeOption);
            }
Beispiel #4
0
 internal AtomMaterializerLog(ResponseInfo responseInfo)
 {
     this.responseInfo = responseInfo;
     this.mergeOption = responseInfo.MergeOption;
     this.identityStack = new Dictionary<string, ODataEntry>(EqualityComparer<string>.Default);
     this.links = new List<LinkDescriptor>();
 }
 /// <summary>
 /// Retrieves the execution plan for the specified merge option and UseCSharpNullComparisonBehavior flag. May return null if the 
 /// plan for the given merge option and useCSharpNullComparisonBehavior flag is not present.
 /// </summary>
 /// <param name="mergeOption">The merge option for which an execution plan is required.</param>
 /// <param name="useCSharpNullComparisonBehavior">Flag indicating if C# behavior should be used for null comparisons.</param>
 /// <returns>The corresponding execution plan, if it exists; otherwise <c>null</c>.</returns>
 internal ObjectQueryExecutionPlan GetExecutionPlan(MergeOption mergeOption, bool useCSharpNullComparisonBehavior)
 {
     string key = GenerateLocalCacheKey(mergeOption, useCSharpNullComparisonBehavior);
     ObjectQueryExecutionPlan plan;
     _plans.TryGetValue(key, out plan);
     return plan;
 }
        public virtual ObjectResult<CalendarEvent> usp_GetEventsByGuid(string guid, MergeOption mergeOption)
        {
            var guidParameter = guid != null ?
                new ObjectParameter("Guid", guid) :
                new ObjectParameter("Guid", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<CalendarEvent>("usp_GetEventsByGuid", mergeOption, guidParameter);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityTrackingAdapter" /> class.
 /// </summary>
 /// <param name="entityTracker">The entity tracker.</param>
 /// <param name="mergeOption">The merge option.</param>
 /// <param name="model">The model.</param>
 /// <param name="context">The context.</param>
 internal EntityTrackingAdapter(EntityTrackerBase entityTracker, MergeOption mergeOption, ClientEdmModel model, DataServiceContext context)
 {
     this.MaterializationLog = new AtomMaterializerLog(mergeOption, model, entityTracker);
     this.MergeOption = mergeOption;
     this.EntityTracker = entityTracker;
     this.Model = model;
     this.Context = context;
 }
        public virtual ObjectResult<User> usp_SearchUserByName(string usernamePrefix, MergeOption mergeOption)
        {
            var usernamePrefixParameter = usernamePrefix != null ?
                new ObjectParameter("UsernamePrefix", usernamePrefix) :
                new ObjectParameter("UsernamePrefix", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<User>("usp_SearchUserByName", mergeOption, usernamePrefixParameter);
        }
Beispiel #9
0
    public virtual ObjectResult<M_寻呼> M_寻呼_列表(string account, MergeOption mergeOption)
    {
        var accountParameter = account != null ?
            new ObjectParameter("Account", account) :
            new ObjectParameter("Account", typeof(string));

        return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<M_寻呼>("M_寻呼_列表", mergeOption, accountParameter);
    }
     public virtual ObjectResult<Location> usp_search_locations(string search, MergeOption mergeOption)
     {
         var searchParameter = search != null ?
             new ObjectParameter("search", search) :
             new ObjectParameter("search", typeof(string));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Location>("usp_search_locations", mergeOption, searchParameter);
     }
     public virtual ObjectResult<Location> usp_area_locations(Nullable<int> area_id, MergeOption mergeOption)
     {
         var area_idParameter = area_id.HasValue ?
             new ObjectParameter("area_id", area_id) :
             new ObjectParameter("area_id", typeof(int));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Location>("usp_area_locations", mergeOption, area_idParameter);
     }
        public virtual ObjectResult<StudentGrade> GetStudentGrades(Nullable<int> studentID, MergeOption mergeOption)
        {
            var studentIDParameter = studentID.HasValue ?
                new ObjectParameter("StudentID", studentID) :
                new ObjectParameter("StudentID", typeof(int));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<StudentGrade>("GetStudentGrades", mergeOption, studentIDParameter);
        }
        public virtual ObjectResult<Customer> FunGetCustomer(Nullable<int> userid, MergeOption mergeOption)
        {
            var useridParameter = userid.HasValue ?
                new ObjectParameter("userid", userid) :
                new ObjectParameter("userid", typeof(int));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Customer>("FunGetCustomer", mergeOption, useridParameter);
        }
        public virtual ObjectResult<letter> quickSearch(string search_terms, MergeOption mergeOption)
        {
            var search_termsParameter = search_terms != null ?
                new ObjectParameter("search_terms", search_terms) :
                new ObjectParameter("search_terms", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<letter>("quickSearch", mergeOption, search_termsParameter);
        }
     public virtual ObjectResult<OfficeMf> OfficesInBuildingStoredProc(Nullable<System.Guid> buildingId, MergeOption mergeOption)
     {
         var buildingIdParameter = buildingId.HasValue ?
             new ObjectParameter("BuildingId", buildingId) :
             new ObjectParameter("BuildingId", typeof(System.Guid));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<OfficeMf>("OfficesInBuildingStoredProc", mergeOption, buildingIdParameter);
     }
     public virtual ObjectResult<Invoice> spVendorInvoices(Nullable<int> vendorID, MergeOption mergeOption)
     {
         var vendorIDParameter = vendorID.HasValue ?
             new ObjectParameter("VendorID", vendorID) :
             new ObjectParameter("VendorID", typeof(int));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Invoice>("spVendorInvoices", mergeOption, vendorIDParameter);
     }
     public virtual ObjectResult<Error> GetError_ById(Nullable<int> id, MergeOption mergeOption)
     {
         var idParameter = id.HasValue ?
             new ObjectParameter("Id", id) :
             new ObjectParameter("Id", typeof(int));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Error>("GetError_ById", mergeOption, idParameter);
     }
Beispiel #18
0
        public virtual ObjectResult<bq_Part> bq_Part_GetById(Nullable<byte> partId, MergeOption mergeOption)
        {
            var partIdParameter = partId.HasValue ?
                new ObjectParameter("partId", partId) :
                new ObjectParameter("partId", typeof(byte));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<bq_Part>("bq_Part_GetById", mergeOption, partIdParameter);
        }
     public virtual ObjectResult<Person> SelectStudentsByCourseNo(Nullable<System.Guid> courseID, MergeOption mergeOption)
     {
         var courseIDParameter = courseID.HasValue ?
             new ObjectParameter("CourseID", courseID) :
             new ObjectParameter("CourseID", typeof(System.Guid));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Person>("SelectStudentsByCourseNo", mergeOption, courseIDParameter);
     }
     public virtual ObjectResult<Product> GetProduct(Nullable<int> productID, MergeOption mergeOption)
     {
         var productIDParameter = productID.HasValue ?
             new ObjectParameter("ProductID", productID) :
             new ObjectParameter("ProductID", typeof(int));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Product>("GetProduct", mergeOption, productIDParameter);
     }
        public virtual ObjectQueryExecutionPlan Prepare(
            ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, bool streaming, Span span,
            IEnumerable<Tuple<ObjectParameter, QueryParameterExpression>> compiledQueryParameters, AliasGenerator aliasGenerator)
        {
            var treeResultType = tree.Query.ResultType;

            // Rewrite this tree for Span?
            DbExpression spannedQuery;
            SpanIndex spanInfo;
            if (ObjectSpanRewriter.TryRewrite(tree, span, mergeOption, aliasGenerator, out spannedQuery, out spanInfo))
            {
                tree = DbQueryCommandTree.FromValidExpression(
                    tree.MetadataWorkspace, tree.DataSpace, spannedQuery, tree.UseDatabaseNullSemantics);
            }
            else
            {
                spanInfo = null;
            }

            var entityDefinition = CreateCommandDefinition(context, tree);

            var shaperFactory = Translator.TranslateColumnMap(
                _translator, elementType, entityDefinition.CreateColumnMap(null),
                context.MetadataWorkspace, spanInfo, mergeOption, streaming, false);

            // attempt to determine entity information for this query (e.g. which entity type and which entity set)

            EntitySet singleEntitySet = null;

            // determine if the entity set is unambiguous given the entity type
            if (treeResultType.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType
                && entityDefinition.EntitySets != null)
            {
                foreach (var entitySet in entityDefinition.EntitySets)
                {
                    if (entitySet != null
                        && entitySet.ElementType.IsAssignableFrom(((CollectionType)treeResultType.EdmType).TypeUsage.EdmType))
                    {
                        if (singleEntitySet == null)
                        {
                            // found a single match
                            singleEntitySet = entitySet;
                        }
                        else
                        {
                            // there's more than one matching entity set
                            singleEntitySet = null;
                            break;
                        }
                    }
                }
            }

            return new ObjectQueryExecutionPlan(
                entityDefinition, shaperFactory, treeResultType, mergeOption, streaming, singleEntitySet, compiledQueryParameters);
        }
Beispiel #22
0
 internal MaterializeAtom(ResponseInfo responseInfo, QueryComponents queryComponents, ProjectionPlan plan, IODataResponseMessage responseMessage, ODataPayloadKind payloadKind)
 {
     Type type;
     this.responseInfo = responseInfo;
     this.elementType = queryComponents.LastSegmentType;
     this.MergeOptionValue = responseInfo.MergeOption;
     this.expectingPrimitiveValue = PrimitiveType.IsKnownNullableType(this.elementType);
     Type materializerType = GetTypeForMaterializer(this.expectingPrimitiveValue, this.elementType, responseInfo.MaxProtocolVersion, out type);
     this.materializer = ODataMaterializer.CreateMaterializerForMessage(responseMessage, responseInfo, materializerType, queryComponents, plan, payloadKind);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedAndEntryMaterializerAdapter"/> class. Used for tests so no ODataMessageReader is required
 /// </summary>
 /// <param name="odataFormat">The format of the reader.</param>
 /// <param name="reader">The reader.</param>
 /// <param name="model">The model.</param>
 /// <param name="mergeOption">The mergeOption.</param>
 internal FeedAndEntryMaterializerAdapter(ODataFormat odataFormat, ODataReaderWrapper reader, ClientEdmModel model, MergeOption mergeOption)
 {
     this.readODataFormat = odataFormat;
     this.clientEdmModel = model;
     this.mergeOption = mergeOption;
     this.reader = reader;
     this.currentEntry = null;
     this.currentFeed = null;
     this.feedEntries = null;
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new <see cref="AtomMaterializerLog"/> instance.
 /// </summary>
 /// <param name="context">Associated data context for the log.</param>
 /// <param name="mergeOption">Merge option used to apply changes.</param>
 /// <remarks>
 /// Note that the merge option can't be changed.
 /// </remarks>
 internal AtomMaterializerLog(DataServiceContext context, MergeOption mergeOption)
 {
     Debug.Assert(context != null, "context != null");
     this.appendOnlyEntries = new Dictionary<string, AtomEntry>(EqualityComparer<String>.Default);
     this.context = context;
     this.mergeOption = mergeOption;
     this.foundEntriesWithMedia = new Dictionary<String, AtomEntry>(EqualityComparer<String>.Default);
     this.identityStack = new Dictionary<String, AtomEntry>(EqualityComparer<String>.Default);
     this.links = new List<LinkDescriptor>();
 }
Beispiel #25
0
 internal MaterializeAtom(ResponseInfo responseInfo, IEnumerable<ODataEntry> entries, Type elementType)
 {
     Type type;
     this.responseInfo = responseInfo;
     this.elementType = elementType;
     this.MergeOptionValue = responseInfo.MergeOption;
     this.expectingPrimitiveValue = PrimitiveType.IsKnownNullableType(elementType);
     Type expectedType = GetTypeForMaterializer(this.expectingPrimitiveValue, this.elementType, responseInfo.MaxProtocolVersion, out type);
     QueryComponents queryComponents = new QueryComponents(null, Util.DataServiceVersionEmpty, elementType, null, null);
     this.materializer = new ODataEntriesEntityMaterializer(entries, responseInfo, queryComponents, expectedType, null);
 }
        /// <summary>
        /// Initializes a new <see cref="AtomMaterializerLog"/> instance.
        /// </summary>
        /// <param name="mergeOption">The merge option for the log.</param>
        /// <param name="model">The model for the log.</param>
        /// <param name="entityTracker">The entity tracker for the log.</param>
        /// <remarks>
        /// Note that the merge option can't be changed.
        /// </remarks>
        internal AtomMaterializerLog(MergeOption mergeOption, ClientEdmModel model, EntityTrackerBase entityTracker)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(entityTracker != null, "entityTracker != null");

            this.appendOnlyEntries = new Dictionary<Uri, ODataEntry>(EqualityComparer<Uri>.Default);
            this.mergeOption = mergeOption;
            this.clientEdmModel = model;
            this.entityTracker = entityTracker;
            this.identityStack = new Dictionary<Uri, ODataEntry>(EqualityComparer<Uri>.Default);
            this.links = new List<LinkDescriptor>();
        }
Beispiel #27
0
        protected XrmServiceContext CreateXrmServiceContext(MergeOption? mergeOption = null)
        {
            string organizationUri = ConfigurationManager.AppSettings["organizationUri"];

            //IServiceManagement<IOrganizationService> OrganizationServiceManagement = null;
            //AuthenticationProviderType OrgAuthType;
            //AuthenticationCredentials authCredentials = null;
            //AuthenticationCredentials tokenCredentials = null;
            //OrganizationServiceProxy organizationProxy = null;
            //SecurityTokenResponse responseToken = null;

            //try
            //{
            //    OrganizationServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUri));
            //    OrgAuthType = OrganizationServiceManagement.AuthenticationType;
            //    authCredentials = GetCredentials(OrgAuthType);
            //    tokenCredentials = OrganizationServiceManagement.Authenticate(authCredentials);
            //    organizationProxy = null;
            //    responseToken = tokenCredentials.SecurityTokenResponse;
            //}
            //catch
            //{
            //    Session["redirect"] = true;
            //}

            IServiceManagement<IOrganizationService> OrganizationServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUri));
            AuthenticationProviderType OrgAuthType = OrganizationServiceManagement.AuthenticationType;
            AuthenticationCredentials authCredentials = GetCredentials(OrgAuthType);
            AuthenticationCredentials tokenCredentials = OrganizationServiceManagement.Authenticate(authCredentials);
            OrganizationServiceProxy organizationProxy = null;
            SecurityTokenResponse responseToken = tokenCredentials.SecurityTokenResponse;

            if (ConfigurationManager.AppSettings["CRM_AuthenticationType"] == "ActiveDirectory")
            {
                using (organizationProxy = new OrganizationServiceProxy(OrganizationServiceManagement, authCredentials.ClientCredentials))
                {
                    organizationProxy.EnableProxyTypes();
                }
            }
            else
            {
                using (organizationProxy = new OrganizationServiceProxy(OrganizationServiceManagement, responseToken))
                {
                    organizationProxy.EnableProxyTypes();
                }
            }

            IOrganizationService service = (IOrganizationService)organizationProxy;

            var context = new XrmServiceContext(service);
            if (context != null && mergeOption != null) context.MergeOption = mergeOption.Value;
            return context;
        }
     public virtual ObjectResult<Error> ListErrors(Nullable<int> fromId, Nullable<int> toId, MergeOption mergeOption)
     {
         var fromIdParameter = fromId.HasValue ?
             new ObjectParameter("fromId", fromId) :
             new ObjectParameter("fromId", typeof(int));
 
         var toIdParameter = toId.HasValue ?
             new ObjectParameter("toId", toId) :
             new ObjectParameter("toId", typeof(int));
 
         return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Error>("ListErrors", mergeOption, fromIdParameter, toIdParameter);
     }
        public virtual ObjectResult<Project> Projects4Employee(string firstName, string lastName, MergeOption mergeOption)
        {
            var firstNameParameter = firstName != null ?
                new ObjectParameter("FirstName", firstName) :
                new ObjectParameter("FirstName", typeof(string));

            var lastNameParameter = lastName != null ?
                new ObjectParameter("LastName", lastName) :
                new ObjectParameter("LastName", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Project>("Projects4Employee", mergeOption, firstNameParameter, lastNameParameter);
        }
        public virtual ObjectResult<OutgoingSingleCredit> ProcessOutgoingSingleCredit(string tRN, string date, MergeOption mergeOption)
        {
            var tRNParameter = tRN != null ?
                new ObjectParameter("TRN", tRN) :
                new ObjectParameter("TRN", typeof(string));

            var dateParameter = date != null ?
                new ObjectParameter("Date", date) :
                new ObjectParameter("Date", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<OutgoingSingleCredit>("ProcessOutgoingSingleCredit", mergeOption, tRNParameter, dateParameter);
        }
Beispiel #31
0
 internal abstract Task <ObjectResult> ExecuteInternalAsync(MergeOption mergeOption, CancellationToken cancellationToken);
Beispiel #32
0
 public virtual ObjectResult <Customer> fun_getAllCustomerss(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Customer>("fun_getAllCustomerss", mergeOption));
 }
Beispiel #33
0
 public virtual ObjectResult <cargo> SP_CARGO_GetAll(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <cargo>("SP_CARGO_GetAll", mergeOption));
 }
        public virtual ObjectResult <WareHouseMng_WareHouseSearchResult_View> WareHouseMng_function_SearchWareHouse(string sortedBy, string sortedDirection, MergeOption mergeOption)
        {
            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <WareHouseMng_WareHouseSearchResult_View>("WareHouseMng_function_SearchWareHouse", mergeOption, sortedByParameter, sortedDirectionParameter));
        }
        public virtual ObjectResult <tblCurso> GetCursosDisponible(Nullable <int> idHora, Nullable <int> idDia, Nullable <int> idSemana, MergeOption mergeOption)
        {
            var idHoraParameter = idHora.HasValue ?
                                  new ObjectParameter("idHora", idHora) :
                                  new ObjectParameter("idHora", typeof(int));

            var idDiaParameter = idDia.HasValue ?
                                 new ObjectParameter("idDia", idDia) :
                                 new ObjectParameter("idDia", typeof(int));

            var idSemanaParameter = idSemana.HasValue ?
                                    new ObjectParameter("idSemana", idSemana) :
                                    new ObjectParameter("idSemana", typeof(int));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <tblCurso>("GetCursosDisponible", mergeOption, idHoraParameter, idDiaParameter, idSemanaParameter));
        }
        public virtual ObjectResult <ProductionItemMng_ProductionItem_SearchView> ProductionItemMng_function_SearchProductionItem(string productionItemUD, string productionItemNM, string productionItemVNNM, string factoryWarehouseIDs, Nullable <int> productionItemGroupID, Nullable <int> productionItemMaterialTypeID, Nullable <bool> status, Nullable <int> defaultWarehouseID, Nullable <int> companyID, Nullable <int> productionItemTypeID, Nullable <bool> isAVTGroup, string sortedBy, string sortedDirection, MergeOption mergeOption)
        {
            var productionItemUDParameter = productionItemUD != null ?
                                            new ObjectParameter("ProductionItemUD", productionItemUD) :
                                            new ObjectParameter("ProductionItemUD", typeof(string));

            var productionItemNMParameter = productionItemNM != null ?
                                            new ObjectParameter("ProductionItemNM", productionItemNM) :
                                            new ObjectParameter("ProductionItemNM", typeof(string));

            var productionItemVNNMParameter = productionItemVNNM != null ?
                                              new ObjectParameter("ProductionItemVNNM", productionItemVNNM) :
                                              new ObjectParameter("ProductionItemVNNM", typeof(string));

            var factoryWarehouseIDsParameter = factoryWarehouseIDs != null ?
                                               new ObjectParameter("FactoryWarehouseIDs", factoryWarehouseIDs) :
                                               new ObjectParameter("FactoryWarehouseIDs", typeof(string));

            var productionItemGroupIDParameter = productionItemGroupID.HasValue ?
                                                 new ObjectParameter("ProductionItemGroupID", productionItemGroupID) :
                                                 new ObjectParameter("ProductionItemGroupID", typeof(int));

            var productionItemMaterialTypeIDParameter = productionItemMaterialTypeID.HasValue ?
                                                        new ObjectParameter("ProductionItemMaterialTypeID", productionItemMaterialTypeID) :
                                                        new ObjectParameter("ProductionItemMaterialTypeID", typeof(int));

            var statusParameter = status.HasValue ?
                                  new ObjectParameter("Status", status) :
                                  new ObjectParameter("Status", typeof(bool));

            var defaultWarehouseIDParameter = defaultWarehouseID.HasValue ?
                                              new ObjectParameter("DefaultWarehouseID", defaultWarehouseID) :
                                              new ObjectParameter("DefaultWarehouseID", typeof(int));

            var companyIDParameter = companyID.HasValue ?
                                     new ObjectParameter("CompanyID", companyID) :
                                     new ObjectParameter("CompanyID", typeof(int));

            var productionItemTypeIDParameter = productionItemTypeID.HasValue ?
                                                new ObjectParameter("ProductionItemTypeID", productionItemTypeID) :
                                                new ObjectParameter("ProductionItemTypeID", typeof(int));

            var isAVTGroupParameter = isAVTGroup.HasValue ?
                                      new ObjectParameter("isAVTGroup", isAVTGroup) :
                                      new ObjectParameter("isAVTGroup", typeof(bool));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <ProductionItemMng_ProductionItem_SearchView>("ProductionItemMng_function_SearchProductionItem", mergeOption, productionItemUDParameter, productionItemNMParameter, productionItemVNNMParameter, factoryWarehouseIDsParameter, productionItemGroupIDParameter, productionItemMaterialTypeIDParameter, statusParameter, defaultWarehouseIDParameter, companyIDParameter, productionItemTypeIDParameter, isAVTGroupParameter, sortedByParameter, sortedDirectionParameter));
        }
        public virtual ObjectResult <PurchasingInvoice_View> PurchasingCreditNoteMng_function_SearchPurchasingInvoice(Nullable <int> iRequesterID, string sortedBy, string sortedDirection, string invoiceQuerySearch, MergeOption mergeOption)
        {
            var iRequesterIDParameter = iRequesterID.HasValue ?
                                        new ObjectParameter("iRequesterID", iRequesterID) :
                                        new ObjectParameter("iRequesterID", typeof(int));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            var invoiceQuerySearchParameter = invoiceQuerySearch != null ?
                                              new ObjectParameter("invoiceQuerySearch", invoiceQuerySearch) :
                                              new ObjectParameter("invoiceQuerySearch", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <PurchasingInvoice_View>("PurchasingCreditNoteMng_function_SearchPurchasingInvoice", mergeOption, iRequesterIDParameter, sortedByParameter, sortedDirectionParameter, invoiceQuerySearchParameter));
        }
        public virtual ObjectResult <PurchasingCreditNoteMng_PurchasingCreditNote_View> PurchasingCreditNoteMng_function_SearchPurchasingCreditNote(Nullable <int> iRequesterID, string sortedBy, string sortedDirection, string invoiceNo, string bLNo, string supplierNM, string creditNoteNo, Nullable <int> factoryID, MergeOption mergeOption)
        {
            var iRequesterIDParameter = iRequesterID.HasValue ?
                                        new ObjectParameter("iRequesterID", iRequesterID) :
                                        new ObjectParameter("iRequesterID", typeof(int));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            var invoiceNoParameter = invoiceNo != null ?
                                     new ObjectParameter("InvoiceNo", invoiceNo) :
                                     new ObjectParameter("InvoiceNo", typeof(string));

            var bLNoParameter = bLNo != null ?
                                new ObjectParameter("BLNo", bLNo) :
                                new ObjectParameter("BLNo", typeof(string));

            var supplierNMParameter = supplierNM != null ?
                                      new ObjectParameter("SupplierNM", supplierNM) :
                                      new ObjectParameter("SupplierNM", typeof(string));

            var creditNoteNoParameter = creditNoteNo != null ?
                                        new ObjectParameter("CreditNoteNo", creditNoteNo) :
                                        new ObjectParameter("CreditNoteNo", typeof(string));

            var factoryIDParameter = factoryID.HasValue ?
                                     new ObjectParameter("FactoryID", factoryID) :
                                     new ObjectParameter("FactoryID", typeof(int));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <PurchasingCreditNoteMng_PurchasingCreditNote_View>("PurchasingCreditNoteMng_function_SearchPurchasingCreditNote", mergeOption, iRequesterIDParameter, sortedByParameter, sortedDirectionParameter, invoiceNoParameter, bLNoParameter, supplierNMParameter, creditNoteNoParameter, factoryIDParameter));
        }
Beispiel #39
0
        public virtual ObjectResult <QuotationMng_FactoryOrderSearchResult_View> QuotationMng_function_SearchFactoryOrder(string season, Nullable <int> factoryID, string factoryOrderUD, string sortedBy, string sortedDirection, MergeOption mergeOption)
        {
            var seasonParameter = season != null ?
                                  new ObjectParameter("Season", season) :
                                  new ObjectParameter("Season", typeof(string));

            var factoryIDParameter = factoryID.HasValue ?
                                     new ObjectParameter("FactoryID", factoryID) :
                                     new ObjectParameter("FactoryID", typeof(int));

            var factoryOrderUDParameter = factoryOrderUD != null ?
                                          new ObjectParameter("FactoryOrderUD", factoryOrderUD) :
                                          new ObjectParameter("FactoryOrderUD", typeof(string));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <QuotationMng_FactoryOrderSearchResult_View>("QuotationMng_function_SearchFactoryOrder", mergeOption, seasonParameter, factoryIDParameter, factoryOrderUDParameter, sortedByParameter, sortedDirectionParameter));
        }
        /// <summary>
        /// attach the link with the given source, sourceProperty and target.
        /// </summary>
        /// <param name="source">source entity of the link.</param>
        /// <param name="sourceProperty">name of the property on the source entity.</param>
        /// <param name="target">target entity of the link.</param>
        /// <param name="linkMerge">merge option to be used to merge the link if there is an existing link.</param>
        internal override void AttachLink(object source, string sourceProperty, object target, MergeOption linkMerge)
        {
            LinkDescriptor relation = new LinkDescriptor(source, sourceProperty, target, this.model);
            LinkDescriptor existing = this.TryGetLinkDescriptor(source, sourceProperty, target);

            if (existing != null)
            {
                switch (linkMerge)
                {
                case MergeOption.AppendOnly:
                    break;

                case MergeOption.OverwriteChanges:
                    relation = existing;
                    break;

                case MergeOption.PreserveChanges:
                    if ((EntityStates.Added == existing.State) ||
                        (EntityStates.Unchanged == existing.State) ||
                        (EntityStates.Modified == existing.State && null != existing.Target))
                    {
                        relation = existing;
                    }

                    break;

                case MergeOption.NoTracking:     // public API point should throw if link exists
                    throw Error.InvalidOperation(Strings.Context_RelationAlreadyContained);
                }
            }
            else
            {
                if (this.model.GetClientTypeAnnotation(this.model.GetOrCreateEdmType(source.GetType())).GetProperty(sourceProperty, false).IsEntityCollection ||
                    (null == (existing = this.DetachReferenceLink(source, sourceProperty, target, linkMerge))))
                {
                    this.AddLink(relation);
                    this.IncrementChange(relation);
                }
                else if (!((MergeOption.AppendOnly == linkMerge) ||
                           (MergeOption.PreserveChanges == linkMerge && EntityStates.Modified == existing.State)))
                {
                    // AppendOnly doesn't change state or target
                    // OverWriteChanges changes target and state
                    // PreserveChanges changes target if unchanged, leaves modified target and state alone
                    relation = existing;
                }
            }

            relation.State = EntityStates.Unchanged;
        }
Beispiel #41
0
 internal abstract ObjectResult ExecuteInternal(MergeOption mergeOption);
        public virtual ObjectResult <ProductionItemMng_FactoryWarehouseSearchResultVirtual_View> ProductionItemMng_function_FactoryWarehouseSearchResult(Nullable <int> productionItemTypeID, string productionItemUD, string productionItemNM, string productionItemVNNM, Nullable <int> productionItemGroupID, Nullable <bool> isAVTGroup, Nullable <int> factoryWarehouseID, Nullable <int> companyID, string sortBy, string sortDirection, MergeOption mergeOption)
        {
            var productionItemTypeIDParameter = productionItemTypeID.HasValue ?
                                                new ObjectParameter("ProductionItemTypeID", productionItemTypeID) :
                                                new ObjectParameter("ProductionItemTypeID", typeof(int));

            var productionItemUDParameter = productionItemUD != null ?
                                            new ObjectParameter("ProductionItemUD", productionItemUD) :
                                            new ObjectParameter("ProductionItemUD", typeof(string));

            var productionItemNMParameter = productionItemNM != null ?
                                            new ObjectParameter("ProductionItemNM", productionItemNM) :
                                            new ObjectParameter("ProductionItemNM", typeof(string));

            var productionItemVNNMParameter = productionItemVNNM != null ?
                                              new ObjectParameter("ProductionItemVNNM", productionItemVNNM) :
                                              new ObjectParameter("ProductionItemVNNM", typeof(string));

            var productionItemGroupIDParameter = productionItemGroupID.HasValue ?
                                                 new ObjectParameter("ProductionItemGroupID", productionItemGroupID) :
                                                 new ObjectParameter("ProductionItemGroupID", typeof(int));

            var isAVTGroupParameter = isAVTGroup.HasValue ?
                                      new ObjectParameter("IsAVTGroup", isAVTGroup) :
                                      new ObjectParameter("IsAVTGroup", typeof(bool));

            var factoryWarehouseIDParameter = factoryWarehouseID.HasValue ?
                                              new ObjectParameter("FactoryWarehouseID", factoryWarehouseID) :
                                              new ObjectParameter("FactoryWarehouseID", typeof(int));

            var companyIDParameter = companyID.HasValue ?
                                     new ObjectParameter("CompanyID", companyID) :
                                     new ObjectParameter("CompanyID", typeof(int));

            var sortByParameter = sortBy != null ?
                                  new ObjectParameter("SortBy", sortBy) :
                                  new ObjectParameter("SortBy", typeof(string));

            var sortDirectionParameter = sortDirection != null ?
                                         new ObjectParameter("SortDirection", sortDirection) :
                                         new ObjectParameter("SortDirection", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <ProductionItemMng_FactoryWarehouseSearchResultVirtual_View>("ProductionItemMng_function_FactoryWarehouseSearchResult", mergeOption, productionItemTypeIDParameter, productionItemUDParameter, productionItemNMParameter, productionItemVNNMParameter, productionItemGroupIDParameter, isAVTGroupParameter, factoryWarehouseIDParameter, companyIDParameter, sortByParameter, sortDirectionParameter));
        }
Beispiel #43
0
 public virtual ObjectResult <Student> sp_Student_All(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Student>("sp_Student_All", mergeOption));
 }
Beispiel #44
0
        // <summary>
        // Constructs a wrapper as part of the materialization process.  This constructor is only used
        // during materialization where it is known that the entity being wrapped is newly constructed.
        // This means that some checks are not performed that might be needed when thw wrapper is
        // created at other times, and information such as the identity type is passed in because
        // it is readily available in the materializer.
        // </summary>
        // <param name="entity"> The entity to wrap </param>
        // <param name="relationshipManager"> The RelationshipManager associated with this entity </param>
        // <param name="entitySet"> The entity set, or null if none is known </param>
        // <param name="context"> The context to which the entity should be attached </param>
        // <param name="mergeOption"> NoTracking for non-tracked entities, AppendOnly otherwise </param>
        // <param name="identityType"> The type of the entity ignoring any possible proxy type </param>
        protected BaseEntityWrapper(
            TEntity entity, RelationshipManager relationshipManager, EntitySet entitySet, ObjectContext context, MergeOption mergeOption,
            Type identityType, bool overridesEquals)
        {
            Debug.Assert(!(entity is IEntityWrapper), "Object is an IEntityWrapper instance instead of the raw entity.");
            DebugCheck.NotNull(entity);

            if (relationshipManager == null)
            {
                throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull);
            }

            _identityType        = identityType;
            _relationshipManager = relationshipManager;

            if (overridesEquals)
            {
                _flags = WrapperFlags.OverridesEquals;
            }

            RelationshipManager.SetWrappedOwner(this, entity);

            if (entitySet != null)
            {
                Context     = context;
                MergeOption = mergeOption;
                RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
            }
        }
Beispiel #45
0
        public virtual ObjectResult <Student> sp_Student_Add(string name, string contact, string city, string address, MergeOption mergeOption)
        {
            var nameParameter = name != null ?
                                new ObjectParameter("Name", name) :
                                new ObjectParameter("Name", typeof(string));

            var contactParameter = contact != null ?
                                   new ObjectParameter("Contact", contact) :
                                   new ObjectParameter("Contact", typeof(string));

            var cityParameter = city != null ?
                                new ObjectParameter("City", city) :
                                new ObjectParameter("City", typeof(string));

            var addressParameter = address != null ?
                                   new ObjectParameter("Address", address) :
                                   new ObjectParameter("Address", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Student>("sp_Student_Add", mergeOption, nameParameter, contactParameter, cityParameter, addressParameter));
        }
Beispiel #46
0
 public virtual ObjectResult <Clientes> ListarClientes(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Clientes>("ListarClientes", mergeOption));
 }
 public virtual ObjectResult <tblEdificio> GetEdificios(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <tblEdificio>("GetEdificios", mergeOption));
 }
        public virtual ObjectResult <User> usp_SearchUserByName(string usernamePrefix, MergeOption mergeOption)
        {
            var usernamePrefixParameter = usernamePrefix != null ?
                                          new ObjectParameter("UsernamePrefix", usernamePrefix) :
                                          new ObjectParameter("UsernamePrefix", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <User>("usp_SearchUserByName", mergeOption, usernamePrefixParameter));
        }
        internal override ObjectQueryExecutionPlan GetExecutionPlan(MergeOption?forMergeOption)
        {
            Debug.Assert(this.Span == null, "Include span specified on compiled LINQ-based ObjectQuery instead of within the expression tree?");
            Debug.Assert(this._cachedPlan == null, "Cached plan should not be set on compiled LINQ queries");

            // Metadata is required to generate the execution plan or to retrieve it from the cache.
            this.ObjectContext.EnsureMetadata();

            ObjectQueryExecutionPlan plan        = null;
            CompiledQueryCacheEntry  cacheEntry  = this._cacheEntry;
            bool useCSharpNullComparisonBehavior = this.ObjectContext.ContextOptions.UseCSharpNullComparisonBehavior;

            if (cacheEntry != null)
            {
                // The cache entry has already been retrieved, so compute the effective merge option with the following precedence:
                // 1. The merge option specified as the argument to Execute(MergeOption), and so to this method
                // 2. The merge option set using ObjectQuery.MergeOption
                // 3. The propagated merge option as recorded in the cache entry
                // 4. The global default merge option.
                MergeOption mergeOption = EnsureMergeOption(forMergeOption, this.UserSpecifiedMergeOption, cacheEntry.PropagatedMergeOption);

                // Ask for the corresponding execution plan
                plan = cacheEntry.GetExecutionPlan(mergeOption, useCSharpNullComparisonBehavior);
                if (plan == null)
                {
                    // Convert the LINQ expression to produce a command tree
                    ExpressionConverter converter       = this.CreateExpressionConverter();
                    DbExpression        queryExpression = converter.Convert();
                    ReadOnlyCollection <KeyValuePair <ObjectParameter, QueryParameterExpression> > parameters = converter.GetParameters();

                    // Prepare the execution plan using the command tree and the computed effective merge option
                    DbQueryCommandTree tree = DbQueryCommandTree.FromValidExpression(this.ObjectContext.MetadataWorkspace, DataSpace.CSpace, queryExpression);
                    plan = ObjectQueryExecutionPlan.Prepare(this.ObjectContext, tree, this.ElementType, mergeOption, converter.PropagatedSpan, parameters, converter.AliasGenerator);

                    // Update and retrieve the execution plan
                    plan = cacheEntry.SetExecutionPlan(plan, useCSharpNullComparisonBehavior);
                }
            }
            else
            {
                // This instance does not yet have a reference to a cache entry.
                // First, attempt to retrieve an existing cache entry.
                QueryCacheManager     cacheManager = this.ObjectContext.MetadataWorkspace.GetQueryCacheManager();
                CompiledQueryCacheKey cacheKey     = new CompiledQueryCacheKey(this._cacheToken);

                if (cacheManager.TryCacheLookup(cacheKey, out cacheEntry))
                {
                    // An entry was found in the cache, so compute the effective merge option based on its propagated merge option,
                    // and use the UseCSharpNullComparisonBehavior flag to retrieve the corresponding execution plan.
                    this._cacheEntry = cacheEntry;
                    MergeOption mergeOption = EnsureMergeOption(forMergeOption, this.UserSpecifiedMergeOption, cacheEntry.PropagatedMergeOption);
                    plan = cacheEntry.GetExecutionPlan(mergeOption, useCSharpNullComparisonBehavior);
                }

                // If no cache entry was found or if the cache entry did not contain the required execution plan, the plan is still null at this point.
                if (plan == null)
                {
                    // The execution plan needs to be produced, so create an appropriate expression converter and generate the query command tree.
                    ExpressionConverter converter       = this.CreateExpressionConverter();
                    DbExpression        queryExpression = converter.Convert();
                    ReadOnlyCollection <KeyValuePair <ObjectParameter, QueryParameterExpression> > parameters = converter.GetParameters();
                    DbQueryCommandTree tree = DbQueryCommandTree.FromValidExpression(this.ObjectContext.MetadataWorkspace, DataSpace.CSpace, queryExpression);

                    // If a cache entry for this compiled query's cache key was not successfully retrieved, then it must be created now.
                    // Note that this is only possible after converting the LINQ expression and discovering the propagated merge option,
                    // which is required in order to create the cache entry.
                    if (cacheEntry == null)
                    {
                        // Create the cache entry using this instance's cache token and the propagated merge option (which may be null)
                        cacheEntry = new CompiledQueryCacheEntry(cacheKey, converter.PropagatedMergeOption);

                        // Attempt to add the entry to the cache. If an entry was added in the meantime, use that entry instead.
                        QueryCacheEntry foundEntry;
                        if (cacheManager.TryLookupAndAdd(cacheEntry, out foundEntry))
                        {
                            cacheEntry = (CompiledQueryCacheEntry)foundEntry;
                        }

                        // We now have a cache entry, so hold onto it for future use.
                        this._cacheEntry = cacheEntry;
                    }

                    // Recompute the effective merge option in case a cache entry was just constructed above
                    MergeOption mergeOption = EnsureMergeOption(forMergeOption, this.UserSpecifiedMergeOption, cacheEntry.PropagatedMergeOption);

                    // Ask the (retrieved or constructed) cache entry for the corresponding execution plan.
                    plan = cacheEntry.GetExecutionPlan(mergeOption, useCSharpNullComparisonBehavior);
                    if (plan == null)
                    {
                        // The plan is not present, so prepare it now using the computed effective merge option
                        plan = ObjectQueryExecutionPlan.Prepare(this.ObjectContext, tree, this.ElementType, mergeOption, converter.PropagatedSpan, parameters, converter.AliasGenerator);

                        // Update the execution plan on the cache entry.
                        // If the execution plan was set in the meantime, SetExecutionPlan will return that value, otherwise it will return 'plan'.
                        plan = cacheEntry.SetExecutionPlan(plan, useCSharpNullComparisonBehavior);
                    }
                }
            }

            // Get parameters from the plan and set them.
            ObjectParameterCollection currentParams = this.EnsureParameters();

            if (plan.CompiledQueryParameters != null && plan.CompiledQueryParameters.Count > 0)
            {
                currentParams.SetReadOnly(false);
                currentParams.Clear();
                foreach (KeyValuePair <ObjectParameter, QueryParameterExpression> pair in plan.CompiledQueryParameters)
                {
                    // Parameters retrieved from the CompiledQueryParameters collection must be cloned before being added to the query.
                    // The cached plan is shared and when used in multithreaded scenarios failing to clone the parameter would result
                    // in the code below updating the values of shared parameter instances saved in the cached plan and used by all
                    // queries using that plan, regardless of the values they were actually invoked with, causing incorrect results
                    // when those queries were later executed.
                    //
                    ObjectParameter          convertedParam      = pair.Key.ShallowCopy();
                    QueryParameterExpression parameterExpression = pair.Value;
                    currentParams.Add(convertedParam);
                    if (parameterExpression != null)
                    {
                        convertedParam.Value = parameterExpression.EvaluateParameter(_parameterValues);
                    }
                }
            }
            currentParams.SetReadOnly(true);

            Debug.Assert(plan != null, "Failed to produce an execution plan?");
            return(plan);
        }
        public virtual ObjectResult <AVTPurchasingPriceMng_FactoryQuotationSearchResult_View> AVTPurchasingPriceMng_function_SearchFactoryQuotation(string season, string clientNM, string description, string factoryUD, Nullable <int> itemTypeID, Nullable <int> statusID, Nullable <int> quotationOfferDirectionID, string proformaInvoiceNo, Nullable <int> businessDataStatusID, Nullable <int> shippedStatus, string lDSFrom, string lDSTo, string sortedBy, string sortedDirection, Nullable <int> pageSize, Nullable <int> pageIndex, MergeOption mergeOption)
        {
            var seasonParameter = season != null ?
                                  new ObjectParameter("Season", season) :
                                  new ObjectParameter("Season", typeof(string));

            var clientNMParameter = clientNM != null ?
                                    new ObjectParameter("ClientNM", clientNM) :
                                    new ObjectParameter("ClientNM", typeof(string));

            var descriptionParameter = description != null ?
                                       new ObjectParameter("Description", description) :
                                       new ObjectParameter("Description", typeof(string));

            var factoryUDParameter = factoryUD != null ?
                                     new ObjectParameter("FactoryUD", factoryUD) :
                                     new ObjectParameter("FactoryUD", typeof(string));

            var itemTypeIDParameter = itemTypeID.HasValue ?
                                      new ObjectParameter("ItemTypeID", itemTypeID) :
                                      new ObjectParameter("ItemTypeID", typeof(int));

            var statusIDParameter = statusID.HasValue ?
                                    new ObjectParameter("StatusID", statusID) :
                                    new ObjectParameter("StatusID", typeof(int));

            var quotationOfferDirectionIDParameter = quotationOfferDirectionID.HasValue ?
                                                     new ObjectParameter("QuotationOfferDirectionID", quotationOfferDirectionID) :
                                                     new ObjectParameter("QuotationOfferDirectionID", typeof(int));

            var proformaInvoiceNoParameter = proformaInvoiceNo != null ?
                                             new ObjectParameter("ProformaInvoiceNo", proformaInvoiceNo) :
                                             new ObjectParameter("ProformaInvoiceNo", typeof(string));

            var businessDataStatusIDParameter = businessDataStatusID.HasValue ?
                                                new ObjectParameter("BusinessDataStatusID", businessDataStatusID) :
                                                new ObjectParameter("BusinessDataStatusID", typeof(int));

            var shippedStatusParameter = shippedStatus.HasValue ?
                                         new ObjectParameter("ShippedStatus", shippedStatus) :
                                         new ObjectParameter("ShippedStatus", typeof(int));

            var lDSFromParameter = lDSFrom != null ?
                                   new ObjectParameter("LDSFrom", lDSFrom) :
                                   new ObjectParameter("LDSFrom", typeof(string));

            var lDSToParameter = lDSTo != null ?
                                 new ObjectParameter("LDSTo", lDSTo) :
                                 new ObjectParameter("LDSTo", typeof(string));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            var pageSizeParameter = pageSize.HasValue ?
                                    new ObjectParameter("PageSize", pageSize) :
                                    new ObjectParameter("PageSize", typeof(int));

            var pageIndexParameter = pageIndex.HasValue ?
                                     new ObjectParameter("PageIndex", pageIndex) :
                                     new ObjectParameter("PageIndex", typeof(int));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <AVTPurchasingPriceMng_FactoryQuotationSearchResult_View>("AVTPurchasingPriceMng_function_SearchFactoryQuotation", mergeOption, seasonParameter, clientNMParameter, descriptionParameter, factoryUDParameter, itemTypeIDParameter, statusIDParameter, quotationOfferDirectionIDParameter, proformaInvoiceNoParameter, businessDataStatusIDParameter, shippedStatusParameter, lDSFromParameter, lDSToParameter, sortedByParameter, sortedDirectionParameter, pageSizeParameter, pageIndexParameter));
        }
Beispiel #51
0
        public virtual ObjectResult <Beast> GetUnavailableBeasts(Nullable <System.DateTime> date, MergeOption mergeOption)
        {
            var dateParameter = date.HasValue ?
                                new ObjectParameter("Date", date) :
                                new ObjectParameter("Date", typeof(System.DateTime));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Beast>("GetUnavailableBeasts", mergeOption, dateParameter));
        }
Beispiel #52
0
 /// <summary>Executes the untyped object query with the specified merge option.</summary>
 /// <param name="mergeOption">
 /// The <see cref="T:System.Data.Entity.Core.Objects.MergeOption" /> to use when executing the query.
 /// The default is <see cref="F:System.Data.Entity.Core.Objects.MergeOption.AppendOnly" />.
 /// </param>
 /// <returns>
 /// An <see cref="T:System.Data.Entity.Core.Objects.ObjectResult`1" /> that contains a collection of entity objects returned by the query.
 /// </returns>
 public ObjectResult Execute(MergeOption mergeOption)
 {
     EntityUtil.CheckArgumentMergeOption(mergeOption);
     return(ExecuteInternal(mergeOption));
 }
Beispiel #53
0
 public virtual ObjectResult <Location> fun_getLocations(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Location>("fun_getLocations", mergeOption));
 }
        /// <summary>response materialization has an identity to attach to the inserted object</summary>
        /// <param name="entityDescriptorFromMaterializer">entity descriptor containing all the information about the entity from the response.</param>
        /// <param name="metadataMergeOption">mergeOption based on which EntityDescriptor will be merged.</param>
        internal override void AttachIdentity(EntityDescriptor entityDescriptorFromMaterializer, MergeOption metadataMergeOption)
        {   // insert->unchanged
            Debug.Assert(entityDescriptorFromMaterializer != null, "entityDescriptorFromMaterializer != null");

            this.EnsureIdentityToResource();

            // resource.State == EntityState.Added or Unchanged for second pass of media link
            EntityDescriptor trackedEntityDescriptor = this.entityDescriptors[entityDescriptorFromMaterializer.Entity];

            // make sure we got the right one - server could override identity and we may be tracking another one already.
            this.ValidateDuplicateIdentity(entityDescriptorFromMaterializer.Identity, trackedEntityDescriptor);

            this.DetachResourceIdentity(trackedEntityDescriptor);

            // While processing the response, we need to find out if the given resource was inserted deep
            // If it was, then we need to change the link state from added to unchanged
            if (trackedEntityDescriptor.IsDeepInsert)
            {
                LinkDescriptor end = this.bindings[trackedEntityDescriptor.GetRelatedEnd()];
                end.State = EntityStates.Unchanged;
            }

            trackedEntityDescriptor.Identity = entityDescriptorFromMaterializer.Identity; // always attach the identity
            AtomMaterializerLog.MergeEntityDescriptorInfo(trackedEntityDescriptor, entityDescriptorFromMaterializer, true /*mergeInfo*/, metadataMergeOption);
            trackedEntityDescriptor.State = EntityStates.Unchanged;
            trackedEntityDescriptor.PropertiesToSerialize.Clear();

            // scenario: sucessfully (1) delete an existing entity and (2) add a new entity where the new entity has the same identity as deleted entity
            // where the SaveChanges pass1 will now associate existing identity with new entity
            // but pass2 for the deleted entity will not blindly remove the identity that is now associated with the new identity
            this.identityToDescriptor[entityDescriptorFromMaterializer.Identity] = trackedEntityDescriptor;
        }
Beispiel #55
0
 public virtual ObjectResult <Car> StoredProcedure1(MergeOption mergeOption)
 {
     return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Car>("StoredProcedure1", mergeOption));
 }
Beispiel #56
0
 /// <summary>
 /// Asynchronously executes the untyped object query with the specified merge option.
 /// </summary>
 /// <remarks>
 /// Multiple active operations on the same context instance are not supported.  Use 'await' to ensure
 /// that any asynchronous operations have completed before calling another method on this context.
 /// </remarks>
 /// <param name="mergeOption">
 /// The <see cref="T:System.Data.Entity.Core.Objects.MergeOption" /> to use when executing the query.
 /// The default is <see cref="F:System.Data.Entity.Core.Objects.MergeOption.AppendOnly" />.
 /// </param>
 /// <returns>
 /// A task that represents the asynchronous operation.
 /// The task result contains an an <see cref="T:System.Data.Entity.Core.Objects.ObjectResult`1" />
 /// that contains a collection of entity objects returned by the query.
 /// </returns>
 public Task <ObjectResult> ExecuteAsync(MergeOption mergeOption)
 {
     return(ExecuteAsync(mergeOption, CancellationToken.None));
 }
        public virtual ObjectResult <AVTPurchasingPriceMng_FactoryQuotationSearchResult_View> AVTPurchasingPriceMng_function_GetAdditionalInfo(string season, string iDs, MergeOption mergeOption)
        {
            var seasonParameter = season != null ?
                                  new ObjectParameter("Season", season) :
                                  new ObjectParameter("Season", typeof(string));

            var iDsParameter = iDs != null ?
                               new ObjectParameter("IDs", iDs) :
                               new ObjectParameter("IDs", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <AVTPurchasingPriceMng_FactoryQuotationSearchResult_View>("AVTPurchasingPriceMng_function_GetAdditionalInfo", mergeOption, seasonParameter, iDsParameter));
        }
Beispiel #58
0
        public virtual ObjectResult <Student> sp_Student_Delete(Nullable <int> studentId, MergeOption mergeOption)
        {
            var studentIdParameter = studentId.HasValue ?
                                     new ObjectParameter("studentId", studentId) :
                                     new ObjectParameter("studentId", typeof(int));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <Student>("sp_Student_Delete", mergeOption, studentIdParameter));
        }
Beispiel #59
0
        public virtual ObjectResult <QuotationMng_QuotationSearchResult_View> QuotationMng_function_SearchQuotation(string quotationUD, string season, string factoryUD, string factoryOrderUD, string proformaInvoiceNo, string clientUD, string articleCode, string description, string sortedBy, string sortedDirection, MergeOption mergeOption)
        {
            var quotationUDParameter = quotationUD != null ?
                                       new ObjectParameter("QuotationUD", quotationUD) :
                                       new ObjectParameter("QuotationUD", typeof(string));

            var seasonParameter = season != null ?
                                  new ObjectParameter("Season", season) :
                                  new ObjectParameter("Season", typeof(string));

            var factoryUDParameter = factoryUD != null ?
                                     new ObjectParameter("FactoryUD", factoryUD) :
                                     new ObjectParameter("FactoryUD", typeof(string));

            var factoryOrderUDParameter = factoryOrderUD != null ?
                                          new ObjectParameter("FactoryOrderUD", factoryOrderUD) :
                                          new ObjectParameter("FactoryOrderUD", typeof(string));

            var proformaInvoiceNoParameter = proformaInvoiceNo != null ?
                                             new ObjectParameter("ProformaInvoiceNo", proformaInvoiceNo) :
                                             new ObjectParameter("ProformaInvoiceNo", typeof(string));

            var clientUDParameter = clientUD != null ?
                                    new ObjectParameter("ClientUD", clientUD) :
                                    new ObjectParameter("ClientUD", typeof(string));

            var articleCodeParameter = articleCode != null ?
                                       new ObjectParameter("ArticleCode", articleCode) :
                                       new ObjectParameter("ArticleCode", typeof(string));

            var descriptionParameter = description != null ?
                                       new ObjectParameter("Description", description) :
                                       new ObjectParameter("Description", typeof(string));

            var sortedByParameter = sortedBy != null ?
                                    new ObjectParameter("SortedBy", sortedBy) :
                                    new ObjectParameter("SortedBy", typeof(string));

            var sortedDirectionParameter = sortedDirection != null ?
                                           new ObjectParameter("SortedDirection", sortedDirection) :
                                           new ObjectParameter("SortedDirection", typeof(string));

            return(((IObjectContextAdapter)this).ObjectContext.ExecuteFunction <QuotationMng_QuotationSearchResult_View>("QuotationMng_function_SearchQuotation", mergeOption, quotationUDParameter, seasonParameter, factoryUDParameter, factoryOrderUDParameter, proformaInvoiceNoParameter, clientUDParameter, articleCodeParameter, descriptionParameter, sortedByParameter, sortedDirectionParameter));
        }
        /// <summary>
        /// find and detach link for reference property
        /// </summary>
        /// <param name="source">source entity</param>
        /// <param name="sourceProperty">source entity property name for target entity</param>
        /// <param name="target">target entity</param>
        /// <param name="linkMerge">link merge option</param>
        /// <returns>true if found and not removed</returns>
        internal LinkDescriptor DetachReferenceLink(object source, string sourceProperty, object target, MergeOption linkMerge)
        {
            Debug.Assert(sourceProperty.IndexOf('/') == -1, "sourceProperty.IndexOf('/') == -1");

            LinkDescriptor existing = this.GetLinks(source, sourceProperty).FirstOrDefault();

            if (null != existing)
            {
                if ((target == existing.Target) ||
                    (MergeOption.AppendOnly == linkMerge) ||
                    (MergeOption.PreserveChanges == linkMerge && EntityStates.Modified == existing.State))
                {
                    return(existing);
                }

                // Since we don't support deep insert on reference property, no need to check for deep insert.
                this.DetachExistingLink(existing, false);
                Debug.Assert(!this.Links.Any(o => (o.Source == source) && (o.SourceProperty == sourceProperty)), "only expecting one");
            }

            return(null);
        }