Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Is query.Insert(IEnumerable <T> list) works?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
vladimir matveev  
View profile  
 More options Feb 10 2012, 10:39 am
From: vladimir matveev <donald...@gmail.com>
Date: Fri, 10 Feb 2012 07:39:18 -0800 (PST)
Local: Fri, Feb 10 2012 10:39 am
Subject: Is query.Insert(IEnumerable <T> list) works?
Hi. I need some help. I tried to use this code:

         using (var db = new BltDataModel())
            {
                var reg = new Collection<FileNames>();
                reg.Add(new FileNames { FileName = "fwqffwqwf",Author
= "", bProcTime = DateTime.Now, Processed = false});
...
                var query = new SqlQuery<FileNames>(db);
                query.Insert(reg);
            }

But it always crashes at "SqlDataProviderBase.cs" at
"bc.WriteToServer(rd)". Is it possible to use this type of
query.Insert?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vladimir matveev  
View profile  
 More options Feb 14 2012, 5:59 am
From: vladimir matveev <donald...@gmail.com>
Date: Tue, 14 Feb 2012 02:59:24 -0800 (PST)
Local: Tues, Feb 14 2012 5:59 am
Subject: Re: Is query.Insert(IEnumerable <T> list) works?
Error occurs when working with table which has an identification
column. Insert method is executed well for tables without an id.

At SqlDataProviderBase.cs at code:

foreach (var memberMapper in members)
        bc.ColumnMappings.Add(new
SqlBulkCopyColumnMapping(memberMapper.Ordinal, memberMapper.Name));

"SqlBulkCopyColumnMapping" gets "memberMapper.Ordinal", but if you
have an id column in your table as first column, the first
"memberMapper.Ordinal" value will be 1, next will be 2 and etc.

So, when "WriteToServer" is executing, it calls "object GetValue(int
i)" method, which accesses to the "_members" array. This array
contains n - 1 elements, where "n - 1" - the number of columns in the
table without id. But the value of variable i in the "object
GetValue(int i)" method complies to the value "memberMapper.Ordinal".
The last value of "memberMapper.Ordinal" is "n". But "_members" array
contains "n - 1" elements. It occurs an error.

On 10 фев, 19:39, vladimir matveev <donald...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »