Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am facing one problem, i don't know why this occurs please help.
when i try to get first result of the linq query, query return null value, while in db, there is record.
when i pass PosCustomerID=00445856363109679106 is working corrent no error. but when i pass PosCustomerID=00445856363109679107 its throw an exception:"string must be exactly one character long"

my code query is:

<pre lang="C#"> POSCustomer updCustomer = (from lC in UpdateCustomerDB.POSCustomers
where lC.POSCustomerID == lBShipToAddress.PosCustomerID
select lC).Single();

i also try this:
1)POSCustomer updCustomer = (from lC in UpdateCustomerDB.POSCustomers
where lC.POSCustomerID == lBShipToAddress.PosCustomerID
select lC).SingleOrDefault();
2)
POSCustomer updCustomer = (from lC in UpdateCustomerDB.POSCustomers
where lC.POSCustomerID == lBShipToAddress.PosCustomerID
select lC).FirstOrDefault();
3)
POSCustomer updCustomer = (from lC in UpdateCustomerDB.POSCustomers
where lC.POSCustomerID == lBShipToAddress.PosCustomerID
select lC).First();


my linq.dbml code generated for that fiels are below:

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage=&amp;quot;_POSCustomerID&amp;quot;, DbType=&amp;quot;VarChar(23) NOT NULL&amp;quot;, CanBeNull=false, IsPrimaryKey=true)]
public string POSCustomerID
{
get
{
return this._POSCustomerID;
}
set
{
if ((this._POSCustomerID != value))
{
this.OnPOSCustomerIDChanging(value);
this.SendPropertyChanging();
this._POSCustomerID = value;
this.SendPropertyChanged(&amp;quot;POSCustomerID&amp;quot;);
this.OnPOSCustomerIDChanged();
}
}
}&lt;/pre&gt;</pre>
=
Posted
Updated 8-Dec-15 20:33pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900