Hi,
I'm testing how easy it is to use LLBLGenPro to pull a set of records from two tables
that have no formal relationship defined between them (because that's how our
legacy database is set up).
The following code compiles but throws an "InvalidCastException" when it gets to the "Foreach" statement:
Unable to cast object of type System.DateTime' to
type 'db.EntityClasses.AttributeTypeEntity'.
(There are fields in both tables that are of type DateTime.)
Is there a simple way of doing this? I would prefer to use the Linq interface.
I would rather not have to define every single field in both tables,
and I would prefer to limit database accesses to at most two.
As I understand it, I cannot use "WithPath" because there is not a FK/PK
definition in the database.
protected void joinTest_pullBothTables()
{
using (DataAccessAdapter adp = new DataAccessAdapter(connectionString()))
{
LinqMetaData MD = new LinqMetaData(adp);
var q = from c in MD.AttributeType
join d in MD.Aos on c.AttrTypCd equals d.AosCtgCd
select new
{
cc = c,
dd = d
};
foreach (object o in q)
Response.Write(String.Format("{0} <br>", q.ToString()));
}
}
Thanks!