P
Paolo
I'm getting this error message when running a LINQtoSQL query. My entity
classes are as follows:
[Table(Name="Activities")]
public partial class Activity
{
#region Fields
[Column(IsPrimaryKey = true, DbType="SmallDateTime NOT NULL")]
public DateTime Activity_Date { get; set; }
[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL",
CanBeNull=false)]
public char Activity_Type { get; set; }
[Column(DbType="TinyInt NOT NULL")]
public byte Activity_Distance {get; set; }
[Column(DbType = "Char(10) NOT NULL", CanBeNull=false)]
public string Activity_Duration {get; set; }
[Column(DbType = "Char(35) NOT NULL", CanBeNull=false)]
public string Activity_Route {get; set; }
#endregion
private EntityRef<Type> _Type;
[Association(Name = "Type_Activity", Storage = "_Type",
ThisKey = "Activity_Type", OtherKey = "Type_Id",
IsForeignKey = true, DeleteRule = "NO ACTION")]
public Type Type
{
get { return this._Type.Entity; }
set { this._Type.Entity = value; }
}
}
[Table(Name="Types")]
public partial class Type
{
#region Fields
[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL", CanBeNull
= false)]
public char Type_Id { get; set; }
[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }
#endregion
private EntitySet<Activity> _Activities;
[Association(Storage = "_Activities", ThisKey = "Type_Id", OtherKey
= "Activity_Type")]
public EntitySet<Activity> Activities
{
get { return this._Activities; }
set { this._Activities.Assign(value); }
I am joining on Activities.Activity_Type and Types.Type_Id.
I'd appreciate some guidance on how to overcome this error because I can't
see what I may have done incorrectly.
I don't know if it's relevant but my query is as follows:
private static void GetAct_Types(DBDataContext db)
{
var act_types =
from a in db.Activities
from t in db.Types
where a.Activity_Type == t.Type_Id
select new { a.Activity_Date,
a.Activity_Type,
t.Type_Desc,
a.Activity_Distance,
a.Activity_Duration,
a.Activity_Route};
foreach (var row in act_types)
{
Console.WriteLine("{0}\t; {1}\t; {2}\t; {3}\t; {4}",
row.Activity_Date,
row.Type_Desc,
row.Activity_Distance,
row.Activity_Duration,
row.Activity_Route);
}
}
}
}
classes are as follows:
[Table(Name="Activities")]
public partial class Activity
{
#region Fields
[Column(IsPrimaryKey = true, DbType="SmallDateTime NOT NULL")]
public DateTime Activity_Date { get; set; }
[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL",
CanBeNull=false)]
public char Activity_Type { get; set; }
[Column(DbType="TinyInt NOT NULL")]
public byte Activity_Distance {get; set; }
[Column(DbType = "Char(10) NOT NULL", CanBeNull=false)]
public string Activity_Duration {get; set; }
[Column(DbType = "Char(35) NOT NULL", CanBeNull=false)]
public string Activity_Route {get; set; }
#endregion
private EntityRef<Type> _Type;
[Association(Name = "Type_Activity", Storage = "_Type",
ThisKey = "Activity_Type", OtherKey = "Type_Id",
IsForeignKey = true, DeleteRule = "NO ACTION")]
public Type Type
{
get { return this._Type.Entity; }
set { this._Type.Entity = value; }
}
}
[Table(Name="Types")]
public partial class Type
{
#region Fields
[Column(IsPrimaryKey = true, DbType = "Char(1) NOT NULL", CanBeNull
= false)]
public char Type_Id { get; set; }
[Column(DbType = "Char(8) NOT NULL", CanBeNull = false)]
public char Type_Desc { get; set; }
#endregion
private EntitySet<Activity> _Activities;
[Association(Storage = "_Activities", ThisKey = "Type_Id", OtherKey
= "Activity_Type")]
public EntitySet<Activity> Activities
{
get { return this._Activities; }
set { this._Activities.Assign(value); }
I am joining on Activities.Activity_Type and Types.Type_Id.
I'd appreciate some guidance on how to overcome this error because I can't
see what I may have done incorrectly.
I don't know if it's relevant but my query is as follows:
private static void GetAct_Types(DBDataContext db)
{
var act_types =
from a in db.Activities
from t in db.Types
where a.Activity_Type == t.Type_Id
select new { a.Activity_Date,
a.Activity_Type,
t.Type_Desc,
a.Activity_Distance,
a.Activity_Duration,
a.Activity_Route};
foreach (var row in act_types)
{
Console.WriteLine("{0}\t; {1}\t; {2}\t; {3}\t; {4}",
row.Activity_Date,
row.Type_Desc,
row.Activity_Distance,
row.Activity_Duration,
row.Activity_Route);
}
}
}
}