当前位置: 首页>>代码示例>>C#>>正文


C# Transaction.EnsureEntityValidForStorage方法代码示例

本文整理汇总了C#中Transaction.EnsureEntityValidForStorage方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.EnsureEntityValidForStorage方法的具体用法?C# Transaction.EnsureEntityValidForStorage怎么用?C# Transaction.EnsureEntityValidForStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction.EnsureEntityValidForStorage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddOrUpdateTransaction

        /// <summary>
        /// Adds new transaction to table storage or updates an existing item.
        /// Throws exception when item is not valid, resolving customer external ID failed or if table storage operation fails.
        /// </summary>
        /// <param name="t">Transaction item to add/update</param>
        public void AddOrUpdateTransaction(Transaction t)
        {
            EnsureTransactionHasCustomerInternalID(t);
            t.EnsureEntityValidForStorage();

            var ent = new TransactionTableEntity(t.ID.Value, t.Date.Value, t.InternalRef.Value)
            {
                MvaNumber = t.MvaNumber,
                Amount = t.Amount,
                Description = t.Description,
                CustomerNumber = t.CustomerNumber,
                AccountID = t.AccountID,
                ProductID = t.ProductID,
                NotInvoiceable = t.NotInvoiceable,
                ExternalRecordID = t.ExternalRecordID,
            };

            AddOrUpdateTransaction(ent);
        }
开发者ID:unipluss,项目名称:invoicetransactions,代码行数:24,代码来源:TransactionRepository.cs

示例2: AddToIndex

        /// <summary>
        /// Adds the transaction item to search index. Can also be used for updating existing items by specifying the Transaction.ID value.
        /// Throws exception when item is not valid, resolving customer external ID failed or if search index operation fails.
        /// </summary>
        /// <param name="t"></param>
        public void AddToIndex(Transaction t)
        {
            t.EnsureEntityValidForStorage();

            Guid internalID;
            if (t.InternalRef.HasValue)
            {
                internalID = t.InternalRef.Value;
            }
            else
            {
                Customer c = new CustomerRepository().GetCustomerByExternalID(t.MvaNumber.Value, t.ExternalRef);
                if (c == null)
                {
                    throw new Exception(string.Format("Failed to resolve customer external ID ({0}) to internal", t.ExternalRef));
                }
                internalID = c.InternalID.Value;
            }
            
            var tableEnt = new TransactionTableEntity(t.ID.Value, t.Date.Value, internalID)
            {
                Amount = t.Amount,
                CustomerNumber = t.CustomerNumber,
                AccountID = t.AccountID,
                Description = t.Description,
                MvaNumber = t.MvaNumber,
                ProductID = t.ProductID
            };

            AddToIndex(tableEnt);
        }
开发者ID:unipluss,项目名称:invoicetransactions,代码行数:36,代码来源:SearchRepository.cs

示例3: AddTransactionToUpdateQueue

        /// <summary>
        /// Adds the transaction item to WebJob queues. Workers process each queue item and add them to transaction table and search index.
        /// Can also be used for updating existing items if Transaction.ID is specified.
        /// Also generates ID if it's null and sets Date to DateTime.Now if it isn't set.
        /// </summary>
        /// <param name="t">Transaction item to add/update</param>
        /// <returns>The item that was added to queue. Throws exception when item is not valid or if adding to queue failed.</returns>
        public Transaction AddTransactionToUpdateQueue(Transaction t)
        {
            t.EnsureEntityValidForStorage(true);
            SerializeTransactionAndAddToQueue(t);

            return t;
        }
开发者ID:unipluss,项目名称:invoicetransactions,代码行数:14,代码来源:TransactionRepository.cs


注:本文中的Transaction.EnsureEntityValidForStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。