Merhaba,
Aşağıdaki kodda "object does not match target type" hatası alıyorum, breakpoint'te SetValue işlemine kadar eşleşme olumlu dönüyor propertiy'ler ve tablolar arasında eşleşme
sorunu yok, sorun ne olabilir ?
public
List<Typ_User>
Get_User(out
string message)
{
List<Typ_User>
User = new
List<Typ_User>();
using (DBDataContext
db = new
DBDataContext())
{
try
{
List<Tbl_User>
SelectedDataList = (from dt
in db.Tbl_Users
select dt).ToList();
#region Data Return..
Typ_User User_Typ =
new
Typ_User();
Type Typ_Of_Tbl =
typeof(Tbl_User);
PropertyInfo[] DataFrom = Typ_Of_Tbl.GetProperties();
Type Typ_Of_Typ =
typeof(Tbl_User);
PropertyInfo[] DataTo = Typ_Of_Typ.GetProperties();
if (SelectedDataList !=
null)
{
foreach (Tbl_User
item in SelectedDataList)
{
foreach (PropertyInfo
DataIn in DataFrom)
{
foreach
(PropertyInfo DataOut
in DataTo)
{
if (DataIn.Name == DataOut.Name)
{
DataIn.SetValue(User_Typ, DataOut.GetValue(item));
break;
}
}
}
}
message =
"Data provided";
return User;
}
else
{
message =
"Data not found.";
return
null;
}
#endregion
}
catch (Exception
ex)
{
if (ex
is
SqlException)
{
SqlException sqx = ex
as
SqlException;
if (sqx.Number == 2146232060)
{
message =
"Can not connect to database.";
}
}
else
if (ex
is
ArgumentNullException)
{
message =
"Data not found.";
}
message = ex.Message.ToString();
return
null;
}
}
}
Desteğiniz için şimdiden teşekkürler.
N Bilişim Bilgisayar Danışmanlık San. Ltd. Şti.