T
tshad
I am trying to do this in one statement;
This works:
PropertyType pt1 = propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Sales"; });
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
pt1));
But I can't seem to get this to work:
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; }).PropertyTypeID)));
break;
I get an error:
Cannot convert type 'int' to 'PropertyType'
If I put an (int) in front of it I get the same error.
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(int)(PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; }).PropertyTypeID)));
break;
I have also tried putting parens after the (int) and before the
..PropertyTypeID with same error:
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(int)((PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; })).PropertyTypeID)));
break;
Does it have to be created as an object before?
Intellisense knows that the return is a PropertType as it gives me the list
of properties when I put the "." in - so I would assume that it should be
able to know that I am passing back an int.
Thanks,
Tom
This works:
PropertyType pt1 = propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Sales"; });
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
pt1));
But I can't seem to get this to work:
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; }).PropertyTypeID)));
break;
I get an error:
Cannot convert type 'int' to 'PropertyType'
If I put an (int) in front of it I get the same error.
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(int)(PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; }).PropertyTypeID)));
break;
I have also tried putting parens after the (int) and before the
..PropertyTypeID with same error:
cmd.Parameters.Add(new SqlParameter("@" + "PropertyTypeID",
(int)((PropertyType)(propertyTypesList.Find(delegate(PropertyType pt)
{return pt.Description == "Listing"; })).PropertyTypeID)));
break;
Does it have to be created as an object before?
Intellisense knows that the return is a PropertType as it gives me the list
of properties when I put the "." in - so I would assume that it should be
able to know that I am passing back an int.
Thanks,
Tom