Hey all,
I wonder if anyone has meat same problem I did:
When I'm trying to select joining 3 tables,
ASP.NET throws an
exception somewhere in Linq's expression.
So I decided to move that logic into Mysql stored procedure, which
returns to DBLinq DataSet and the problem I meat is to cast DataRow to
my table entity. I've used little bit of reflection to solve this
problem, but not sure it's best solution.
protected static Object initiateFromDataRow(DataRow row,Type
type)
{
Object res = type.GetConstructor(new Type[] { }).Invoke
(null);
PropertyInfo[] infos = type.GetProperties();
foreach (PropertyInfo info in infos)
{
if ((info.GetCustomAttributes(typeof(ColumnAttribute),
true)).Count() > 0)
info.SetValue(res, row[info.Name], null);
}
return res;
}
Any comments?
Thank you in advance.