How can one read a "sql" system table like sys.tables using DLinq
I have try the following, but no luck - Get "Incorrect syntax near '.'."
string connection = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=AdventureWorks;Data Source=localhost";
System.Data.DLinq.
DataContext tDataContext = new System.Data.DLinq.DataContext( connection ); string sql = "SELECT Name from sys.Tables"; var tables = tDataContext.ExecuteQuery<SysTables>( sql ); // following line errors with "Incorrect syntax near '.'." ObjectDumper.Write( tables ); // <--------- Exception is thrown here
// *** Supporting class ***
[
Table(Name="sys.Tables")] public partial class SysTables : System.Data.DLinq.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged{
private int _Name; public SysTables(){
}
[
Column(Name="Name", Storage="_Name", DBType="nvarchar(128) NOT NULL")][
DataObjectField(false, false, false)] public int Name{
get{
return this._Name;}
set{
if ((this._Name != value)){
this.OnPropertyChanging("Name"); this._Name = value; this.OnPropertyChanged("Name");}
}
}

Read a System Table with DLinq
Namza
I made a couple small changes to your SysTable class and was able to make it work in the ReadOnly scenario--I didn't test update. Currently, DLinq needs an Id property for every entity class, so I added this to the Name class. I also changed the type of SysTables.Name to a string (it was previously an int). The code is below with changes highlighted.
[Table(Name="sys.Tables")]
public partial class SysTables
{
private string _Name;
public SysTables()
{
}
[Column(Name="Name", Storage="_Name", Id=true, DBType="nvarchar(128) NOT NULL")]
public string Name
{
get
{
return this._Name;
}
set
{
if ((this._Name != value))
{
this._Name = value;
}
}
}
}
}
vexsis448
It worked. Thank you!
I have looked at the samples in the CTP and additionally found the help reference for XLinq, but is there a help (reference) file(s) for Linq and/or DLinq
bagofnoise