Back to list
Views:   0
Replies:  0
Reply 1

I too had this same question but was able to figure out what was going on...sort of...

I am actually in the process of implementing this functionality in an application I am working on.

There is a problem though...

If you do not plan to use all of the variables in the SQL statement (such as the below delete command) you will get an error.

Am I missing something?  Didn't anyone test this out?
Below only CustomerID and Version are needed in the SQL.

However, when you use the "Take" functionality you are applying CompanyName, City, and Country to the SQL text event though they are not needed.  This creates an error...

You are actually loading up parameters you are not going to use:

In Oracle, if you attempt to execute this you get:

"ORA-01036: illegal variable name/number"

This means that you are attempting to apply parameters that are not actually in the SQL text.

Do factory folks,

Do you have a solution for this?



private object[] Take(Customer customer)
             return new object[]  
                 "@CustomerId", customer.CustomerId,
                 "@CompanyName", customer.Company,
                 "@City", customer.City,
                 "@Country", customer.Country,
     "@Version", customer.Version.AsByteArray()

public void DeleteCustomer(Customer customer)
            string sql =
            @"DELETE FROM [Customer]
               WHERE CustomerId = @CustomerId 
                AND Version = @Version";

            Db.Update(sql, Take(customer));

Adam Rice, Sep 17, 2012
Launch Sql Server Configuration Manager and go to "SQL Server Services" and you should see the Instance ID's under "Name". the name should read "SQL Server(InstanceIDOfYourInstances). Right now I am showing 3. Make sure it is also running. If it's not running right click and start it. Something else, right click the 2008 express version and go to properties and make sure "Built-in Account: " is selected and "Local System" is selected in the dropdown and restart the service. Make sure you restart.
Aug 05, 2011
Reply 2
Hi Steve,

The purpose of the Take() method is to convert the business object into an array with contains the SQL parameter names and values. This is used in combination with Insert and Update queries in the Data Objects project. 
An example on where this is used can be found in the SqlServerCustomerDao class. On line 90 the Db.Insert method is called with on of the parameters the return value of the Take() method. 

The implementation of the Take() method is shown on line 157. Using the Take() method this way reduces repeated code and makes the function easier to read.

Hope this helps.

Regards, Maurits 
Maurits van Beusekom, Sep 02, 2012
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas