views:

70

answers:

1

Hi,

I'm trying to add a record to a database. My Model is fairly simple: A Project table with a companyId field that associates to a Company table.

Here's were I'm stuck..

var companyTemp = collection["company"];
var company = isspDB.Company.Where(co => co.companyId == 1).First();

What I basically need is:

var company = isspDB.Company.Where(co => co.companyId == collection["company"]).First();

But that doesn't work, "... does not take '1' arguments"

A: 

I'm guessing that the collection contains a string variable. Try comparing the string representation of the companyId to this value and see if that doesn't work. Alternatively, you can parse the integer company id out of the collection and compare it.

var company = isspDB.Company
                    .Where( co => co.companyID.ToString() == collection["company"] )
                    .First();
tvanfosson
parsing the data in the collection to an int worked, thanks!
Karl R