locked
Weird behavior with DbContext SaveChanges RRS feed

  • Question

  • I have a very weird behavior from DbContext.SaveChanges

    I have 2 classes.

    RepCommission:-

    public partial class RepCommission
        {
            public int RepCommissionId { get; set; }
            public long VendorPayId { get; set; }
            public string DealerNumber { get; set; }
            public string NSCC_CODE { get; set; }
            public int RepID { get; set; }
            public string CUSIP { get; set; }
            public string SHLDRALPHA { get; set; }
            public System.DateTime TradeDate { get; set; }
            public Nullable<decimal> AmountInvested { get; set; }
            public decimal DealerCommission { get; set; }
            public string AccountNumber { get; set; }
            public string SocialSecurityNumber { get; set; }
            public Nullable<System.DateTime> BatchDate { get; set; }
            public bool IncludedInCommission { get; set; }
            public Nullable<System.DateTime> CreateDate { get; set; }
            public string EnteredBy { get; set; }
            public string InvestmentName { get; set; }
            public Nullable<decimal> AmountReceived { get; set; }
            public Nullable<System.DateTime> TransDate { get; set; }
            public string SourceRepCode { get; set; }
            public string SourceRepName { get; set; }
            public long CommissionTypeId { get; set; }
    
            public decimal? TicketCharge { get; set; }
            public decimal? CommissionFee { get; set; }
    
            public VendorPayment VendorPayment { get; set; }
        }

    Another class is: VendorPayment

    public partial class VendorPayment
        {
            public long VendorPayId { get; set; }
            public long FirmId { get; set; }
            public System.DateTime Created { get; set; }
            public Nullable<long> VendorID { get; set; }
            public string NSCC_CODE { get; set; }
            public System.DateTime StatEndDate { get; set; }
            public string CheckNumber { get; set; }
            public decimal Amount { get; set; }
            public string Source { get; set; }
            public bool DepositVerif { get; set; }
            public string DepositVerifBy { get; set; }
            public Nullable<System.DateTime> DepositDate { get; set; }
            public string AllocateBy { get; set; }
            public Nullable<System.DateTime> AllocateDate { get; set; }
            public bool IncludeOnRun { get; set; }
            public int CommissionBatchID { get; set; }
            public Nullable<int> CommissionTypeID { get; set; }
    
            public int? Branch { get; set; }
    
            public virtual ICollection<RepCommission> RepCommissions { get; set; }
        }

    I am using POCO with Entity Framework.

    Now,

    VendorPaymentMap is defined as:-

      public class VendorPaymentMap : EntityTypeConfiguration<VendorPayment>
        {
            public VendorPaymentMap()
            {
                // Primary Key
                this.HasKey(t => t.VendorPayId);
    
                // Properties
                this.Property(t => t.NSCC_CODE)
                    .IsRequired()
                    .HasMaxLength(255);
    
                this.Property(t => t.CheckNumber)
                    .IsRequired()
                    .HasMaxLength(50);
    
                this.Property(t => t.Source)
                    .IsRequired()
                    .HasMaxLength(50);
    
                this.Property(t => t.DepositVerifBy)
                    .HasMaxLength(100);
    
                this.Property(t => t.AllocateBy)
                    .HasMaxLength(50);
    
                this.Property(t => t.VendorPayId).IsRequired();
    
                // Table & Column Mappings
                this.ToTable("tblVendorPayments");
                this.Property(t => t.VendorPayId).HasColumnName("VendorPayID");
                this.Property(t => t.FirmId).HasColumnName("FirmID");
                this.Property(t => t.Created).HasColumnName("Created");
                this.Property(t => t.VendorID).HasColumnName("VendorID");
                this.Property(t => t.NSCC_CODE).HasColumnName("NSCC_CODE");
                this.Property(t => t.StatEndDate).HasColumnName("StatEndDate");
                this.Property(t => t.CheckNumber).HasColumnName("CheckNumber");
                this.Property(t => t.Amount).HasColumnName("Amount");
                this.Property(t => t.Source).HasColumnName("Source");
                this.Property(t => t.DepositVerif).HasColumnName("DepositVerif");
                this.Property(t => t.DepositVerifBy).HasColumnName("DepositVerifBy");
                this.Property(t => t.DepositDate).HasColumnName("DepositDate");
                this.Property(t => t.AllocateBy).HasColumnName("AllocateBy");
                this.Property(t => t.AllocateDate).HasColumnName("AllocateDate");
                this.Property(t => t.IncludeOnRun).HasColumnName("IncludeOnRun");
                this.Property(t => t.CommissionBatchID).HasColumnName("CommissionBatchID");
                this.Property(t => t.CommissionTypeID).HasColumnName("CommissionTypeID");
            }
        }

    RepCommissionMap is defined as:-

    public class RepCommissionMap : EntityTypeConfiguration<RepCommission>
        {
            public RepCommissionMap()
            {
                Property(t => t.RepCommissionId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
    
                HasKey(t => t.RepCommissionId);
                
    
                this.Property(t => t.DealerNumber)
                    .IsRequired()
                    .HasMaxLength(50);
    
                this.Property(t => t.NSCC_CODE)
                    .HasMaxLength(50);
    
                this.Property(t => t.RepID)
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
    
                this.Property(t => t.CUSIP)
                    .HasMaxLength(9);
    
                this.Property(t => t.SHLDRALPHA)
                    .HasMaxLength(200);
    
                this.Property(t => t.DealerCommission)
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
    
                this.Property(t => t.AccountNumber)
                    .HasMaxLength(20);
    
                this.Property(t => t.SocialSecurityNumber)
                    .HasMaxLength(50);
    
                this.Property(t => t.EnteredBy)
                    .HasMaxLength(50);
    
                this.Property(t => t.InvestmentName)
                    .HasMaxLength(200);
    
                this.Property(t => t.SourceRepCode)
                    .HasMaxLength(50);
    
                this.Property(t => t.SourceRepName)
                    .HasMaxLength(150);
    
                this.Property(t => t.CommissionTypeId)
                    .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
    
                // Table & Column Mappings
                this.ToTable("tblCommissionsManualInput");
                this.Property(t => t.RepCommissionId).HasColumnName("tblCommissionsManualInputID");
                this.Property(t => t.VendorPayId).HasColumnName("VendorPayID");
                this.Property(t => t.DealerNumber).HasColumnName("DealerNumber");
                this.Property(t => t.NSCC_CODE).HasColumnName("NSCC_CODE");
                this.Property(t => t.RepID).HasColumnName("RepID");
                this.Property(t => t.CUSIP).HasColumnName("CUSIP");
                this.Property(t => t.SHLDRALPHA).HasColumnName("SHLDRALPHA");
                this.Property(t => t.TradeDate).HasColumnName("TradeDate");
                this.Property(t => t.AmountInvested).HasColumnName("AmountInvested");
                this.Property(t => t.DealerCommission).HasColumnName("DealerCommission");
                this.Property(t => t.AccountNumber).HasColumnName("AccountNumber");
                this.Property(t => t.SocialSecurityNumber).HasColumnName("SocialSecurityNumber");
                this.Property(t => t.BatchDate).HasColumnName("BatchDate");
                this.Property(t => t.IncludedInCommission).HasColumnName("IncludedInCommission");
                this.Property(t => t.CreateDate).HasColumnName("CreateDate");
                this.Property(t => t.EnteredBy).HasColumnName("EnteredBy");
                this.Property(t => t.InvestmentName).HasColumnName("InvestmentName");
                this.Property(t => t.AmountReceived).HasColumnName("AmountReceived");
                this.Property(t => t.TransDate).HasColumnName("TransDate");
                this.Property(t => t.SourceRepCode).HasColumnName("SourceRepCode");
                this.Property(t => t.SourceRepName).HasColumnName("SourceRepName");
                this.Property(t => t.CommissionTypeId).HasColumnName("CommissionTypeId");
    
    
                HasRequired(t => t.VendorPayment).WithMany(t => t.RepCommissions).HasForeignKey(t => t.VendorPayId);
            }
        }

    I am trying to save 2 VendorPayment rows in DB and 17 RepCommission rows.

    In Sql Profiler I see that Entity Framework is firing insert command for all the 17 RepCommission.

    But the rep commission entries corresponding to only one vendor payment is getting saved in DB.

    When I look at the RepCommission objects which didn't get saved in DB in debugger in VS, I see that the primary key which is identity column is populated with a number which doesn't even exist in DB.

    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'63009F105',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=4178.90,@7=21.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:28.5414597',@12=N'NANOSPHERE INC',@13=4178.90,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'042682203',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=-2956.35,@7=11.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:28.9114602',@12=N'AROTECH CORP NEW',@13=-2956.35,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'98973P101',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=-4070.93,@7=11.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:29.2214607',@12=N'ZIOPHARM ONCOLOGY INC',@13=-4070.93,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'92823T108',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:29.6114612',@12=N'VIRNETX HOLDING CORP',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'25456U109',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:30.0614618',@12=N'DIRECT MARKETS HOLDINGS CORP',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'427093109',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:30.4414624',@12=N'HERCULES OFFSHORE INC',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'',@4=N'IRA Jackson L',@5='2013-06-03 00:00:00',@6=-730.99,@7=42.25,@8=N'368376794',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:31.6914641',@12=N'PUT: VIRNETX HOLDING CORP',@13=-730.99,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'34407T104',@4=N'Lykken D',@5='2013-06-03 00:00:00',@6=-0.02,@7=0.00,@8=N'462554406',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:32.1814648',@12=N'FLYI INC',@13=-0.02,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'084670702',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=11432.76,@7=51.00,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:32.8814658',@12=N'BERKSHIRE HATHAWAY INC DEL CL B NEW',@13=11432.76,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'09253U108',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=-10826.31,@7=61.00,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:33.3614665',@12=N'BLACKSTONE GROUP LP/THE',@13=-10826.31,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=-1140.98,@7=42.25,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:33.7614670',@12=N'CALL: BLACKSTONE GROUP LP/THE',@13=-1140.98,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'55273N574',@4=N'Dwyer Trust',@5='2013-06-03 00:00:00',@6=-446.00,@7=-2.45,@8=N'706763208',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:38.1614732',@12=N'MFS MUNI INCOME FD CL A',@13=-446.00,@14='2013-06-03 00:00:00',@15=N'076639',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'693391617',@4=N'Dwyer Trust',@5='2013-06-03 00:00:00',@6=-446.00,@7=-2.45,@8=N'706763208',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:38.5314737',@12=N'PIMCO MUNI BOND FD CL A',@13=-446.00,@14='2013-06-03 00:00:00',@15=N'076639',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'63009F105',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=4178.90,@7=21.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:28.5414597',@12=N'NANOSPHERE INC',@13=4178.90,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'042682203',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=-2956.35,@7=11.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:28.9114602',@12=N'AROTECH CORP NEW',@13=-2956.35,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'98973P101',@4=N'Boosalis W',@5='2013-06-03 00:00:00',@6=-4070.93,@7=11.00,@8=N'154913629',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:29.2214607',@12=N'ZIOPHARM ONCOLOGY INC',@13=-4070.93,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'92823T108',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:29.6114612',@12=N'VIRNETX HOLDING CORP',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'25456U109',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:30.0614618',@12=N'DIRECT MARKETS HOLDINGS CORP',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'427093109',@4=N'Gold -Aarp Capi',@5='2013-06-03 00:00:00',@6=0.00,@7=0.00,@8=N'307435049',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:30.4414624',@12=N'HERCULES OFFSHORE INC',@13=0.00,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'',@4=N'IRA Jackson L',@5='2013-06-03 00:00:00',@6=-730.99,@7=42.25,@8=N'368376794',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:31.6914641',@12=N'PUT: VIRNETX HOLDING CORP',@13=-730.99,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'34407T104',@4=N'Lykken D',@5='2013-06-03 00:00:00',@6=-0.02,@7=0.00,@8=N'462554406',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:32.1814648',@12=N'FLYI INC',@13=-0.02,@14='2013-06-03 00:00:00',@15=N'263092',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'084670702',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=11432.76,@7=51.00,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:32.8814658',@12=N'BERKSHIRE HATHAWAY INC DEL CL B NEW',@13=11432.76,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'09253U108',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=-10826.31,@7=61.00,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:33.3614665',@12=N'BLACKSTONE GROUP LP/THE',@13=-10826.31,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'',@4=N'Patte P',@5='2013-06-03 00:00:00',@6=-1140.98,@7=42.25,@8=N'585602292',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:33.7614670',@12=N'CALL: BLACKSTONE GROUP LP/THE',@13=-1140.98,@14='2013-06-03 00:00:00',@15=N'495320',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'55273N574',@4=N'Dwyer Trust',@5='2013-06-03 00:00:00',@6=-446.00,@7=-2.45,@8=N'706763208',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:38.1614732',@12=N'MFS MUNI INCOME FD CL A',@13=-446.00,@14='2013-06-03 00:00:00',@15=N'076639',@16=N'',@17=2
    go
    exec sp_executesql N'insert [dbo].[tblCommissionsManualInput]([VendorPayID], [DealerNumber], [NSCC_CODE], [RepID], [CUSIP], [SHLDRALPHA], [TradeDate], [AmountInvested], [DealerCommission], [AccountNumber], [SocialSecurityNumber], [BatchDate], [IncludedInCommission], [CreateDate], [EnteredBy], [InvestmentName], [AmountReceived], [TransDate], [SourceRepCode], [SourceRepName], [CommissionTypeId], [TicketCharge], [CommissionFee])
    values (@0, @1, null, @2, @3, @4, @5, @6, @7, @8, null, @9, @10, @11, null, @12, @13, @14, @15, @16, @17, null, null)
    select [tblCommissionsManualInputID]
    from [dbo].[tblCommissionsManualInput]
    where @@ROWCOUNT > 0 and [tblCommissionsManualInputID] = scope_identity()',N'@0 bigint,@1 nvarchar(50),@2 int,@3 nvarchar(9),@4 nvarchar(200),@5 datetime2(7),@6 decimal(18,2),@7 decimal(18,2),@8 nvarchar(20),@9 datetime2(7),@10 bit,@11 datetime2(7),@12 nvarchar(200),@13 decimal(18,2),@14 datetime2(7),@15 nvarchar(50),@16 nvarchar(150),@17 bigint',@0=11466,@1=N'13W',@2=0,@3=N'693391617',@4=N'Dwyer Trust',@5='2013-06-03 00:00:00',@6=-446.00,@7=-2.45,@8=N'706763208',@9='1899-01-01 00:00:00',@10=1,@11='2013-06-25 00:38:38.5314737',@12=N'PIMCO MUNI BOND FD CL A',@13=-446.00,@14='2013-06-03 00:00:00',@15=N'076639',@16=N'',@17=2
    go
    
    Please help.


    suneeelid2000@gmail.com

    • Moved by CoolDadTx Tuesday, June 25, 2013 5:54 PM EF related
    Tuesday, June 25, 2013 4:53 AM

Answers

  • Hi sunil,

    I see you are using AddToDbSet method to add the entities. I think it will always try to insert new entities to the context.

    Do you have any methods in the repository to update the entities? If you want to update existing entities, I think you need to Attach the entities to the context?

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by Chester Hong Monday, July 8, 2013 4:40 PM
    Monday, July 1, 2013 10:08 PM

All replies

  • anyone with ideas?

    suneeelid2000@gmail.com

    Tuesday, June 25, 2013 2:53 PM
  • Hi Sunil,

    I think you created new RepCommision entities and then added them to through VendorPayment's RepCommisions navigation property? I think you can try to query from the context to get the VendorPayment and modify the values.

    If this is not the same scenario with yours, could you please post some code to clarify?

    Best regarsds,



    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, June 26, 2013 10:58 PM
  • Here is the code which I am using to insert the data

      private bool ParseCommissionFile(string[] fileLines, string fileSource, Firm firm,Vendor southWestVendor)
            {
                var successfullyParsed   = false;
                var skipHeader           = false;
                var tradeDatesDictionary = new Dictionary<DateTime, VendorPayment>();
                var repCommissions = new List<RepCommission>();
                
                foreach (string line in fileLines)
                {
                    try
                    {
                        if (!skipHeader)
                        {
                            skipHeader = true;
                            continue;
                        }
    
                        var commissionEntry = ParseLineToCommissionEntry(line, fileSource, firm.FirmID);
    
                        DbRepositoryFactory.SouthWestSecurityCommissionRepository.AddToDbSet(commissionEntry);
    
                        if (commissionEntry.TicketCharge.HasValue)
                        {
                            RepCommission repCommission = null;
                            if (!tradeDatesDictionary.ContainsKey(commissionEntry.TradeDate.Value))
                            {
                                var vendorPayment = CreateVendorPayment(commissionEntry, firm.FirmID, southWestVendor.VendorId);
    
                                tradeDatesDictionary.Add(commissionEntry.TradeDate.Value, vendorPayment);
    
                                vendorPayment.RepCommissions.Add(CreateRepCommission(commissionEntry, vendorPayment, southWestVendor.DealerNum));
    
                                DbRepositoryFactory.AddToDbSet(vendorPayment);
                                
                            }
                            else
                            {
                                var vendorPayment = tradeDatesDictionary[commissionEntry.TradeDate.Value];
                                var commission    = commissionEntry.CommissionFee - commissionEntry.TicketCharge;
                                repCommission     = CreateRepCommission(commissionEntry, vendorPayment, southWestVendor.DealerNum);
                                vendorPayment.RepCommissions.Add(repCommission);
                                vendorPayment.Amount += commission ?? 0;
    
                            }
                            repCommissions.Add(repCommission);
                           // DbRepositoryFactory.AddToDbSet(repCommission);
                        }
                        
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Error from Southwest processing", ex);
                        successfullyParsed = false;
                    }
                }
    
                try
                {
                    DbRepositoryFactory.SaveChanges();
    
    
                    //foreach (var repCommission in repCommissions)
                    //    DbRepositoryFactory.AddToDbSet(repCommission);
    
                    //DbRepositoryFactory.SaveChanges();
                    
                    successfullyParsed = true;
                }
                catch (Exception ex)
                {
                    Logger.Error("Error while saving the data", ex);
                    successfullyParsed = false;
                }
    
                return successfullyParsed;
            }

    Here is the code for DbRepsoitoryFactory AddToDbSet method

    public void AddToDbSet<T>(T entity) where T : class
            {
                GetRepository<T>().AddToDbSet(entity);
            }


    suneeelid2000@gmail.com

    Thursday, June 27, 2013 2:18 PM
  • Hi sunil,

    I see you are using AddToDbSet method to add the entities. I think it will always try to insert new entities to the context.

    Do you have any methods in the repository to update the entities? If you want to update existing entities, I think you need to Attach the entities to the context?

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by Chester Hong Monday, July 8, 2013 4:40 PM
    Monday, July 1, 2013 10:08 PM