Chapter 13 Can't see PlanetWroxDataContext
Hello All,
From the following code the all.aspx file can't locate the code in the PlanetWrox designer.cs file in the app_code folder.
The all.aspx file is located in the reviews folder.
the is the code behind of the all.aspx folder
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class All : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
using (PlanetWroxDataContext myDataContext = new PlanetWroxDataContext())
{
var allReviews = from review in myDataContext.Reviews
where Reviews.Authorized == true
orderby review.CreateDateTime descending
select review;
GridView1.DataSource = allReviews;
GridView1.DataBind();
}
}
}
This is the designer.cs file
pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5446
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace tomemail.App_Code
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
[System.Data.Linq.Mapping.DatabaseAttribute(Name="P lanetWrox")]
public partial class PlanetWroxDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void Insertreview(review instance);
partial void Updatereview(review instance);
partial void Deletereview(review instance);
partial void Insertgenre(genre instance);
partial void Updategenre(genre instance);
partial void Deletegenre(genre instance);
#endregion
public PlanetWroxDataContext() :
base(global::System.Configuration.ConfigurationMan ager.ConnectionStrings["PlanetWroxConnectionString1"].ConnectionString, mappingSource)
{
OnCreated();
}
public PlanetWroxDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public PlanetWroxDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public PlanetWroxDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public PlanetWroxDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<review> reviews
{
get
{
return this.GetTable<review>();
}
}
public System.Data.Linq.Table<genre> genres
{
get
{
return this.GetTable<genre>();
}
}
}
[Table(Name="dbo.review")]
public partial class review : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _id;
private string _title;
private string _summary;
private string _body;
private int _genreid;
private bool _authorized;
private System.DateTime _createdatetime;
private System.DateTime _updatedatetime;
private EntityRef<genre> _genre;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnidChanging(int value);
partial void OnidChanged();
partial void OntitleChanging(string value);
partial void OntitleChanged();
partial void OnsummaryChanging(string value);
partial void OnsummaryChanged();
partial void OnbodyChanging(string value);
partial void OnbodyChanged();
partial void OngenreidChanging(int value);
partial void OngenreidChanged();
partial void OnauthorizedChanging(bool value);
partial void OnauthorizedChanged();
partial void OncreatedatetimeChanging(System.DateTime value);
partial void OncreatedatetimeChanged();
partial void OnupdatedatetimeChanging(System.DateTime value);
partial void OnupdatedatetimeChanged();
#endregion
public review()
{
this._genre = default(EntityRef<genre>);
OnCreated();
}
[Column(Storage="_id", DbType="Int NOT NULL", IsPrimaryKey=true)]
public int id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
this.OnidChanging(value);
this.SendPropertyChanging();
this._id = value;
this.SendPropertyChanged("id");
this.OnidChanged();
}
}
}
[Column(Storage="_title", DbType="NVarChar(200) NOT NULL", CanBeNull=false)]
public string title
{
get
{
return this._title;
}
set
{
if ((this._title != value))
{
this.OntitleChanging(value);
this.SendPropertyChanging();
this._title = value;
this.SendPropertyChanged("title");
this.OntitleChanged();
}
}
}
[Column(Storage="_summary", DbType="NVarChar(MAX) NOT NULL", CanBeNull=false)]
public string summary
{
get
{
return this._summary;
}
set
{
if ((this._summary != value))
{
this.OnsummaryChanging(value);
this.SendPropertyChanging();
this._summary = value;
this.SendPropertyChanged("summary");
this.OnsummaryChanged();
}
}
}
[Column(Storage="_body", DbType="NVarChar(MAX)")]
public string body
{
get
{
return this._body;
}
set
{
if ((this._body != value))
{
this.OnbodyChanging(value);
this.SendPropertyChanging();
this._body = value;
this.SendPropertyChanged("body");
this.OnbodyChanged();
}
}
}
[Column(Storage="_genreid", DbType="Int NOT NULL")]
public int genreid
{
get
{
return this._genreid;
}
set
{
if ((this._genreid != value))
{
if (this._genre.HasLoadedOrAssignedValue)
{
throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValu eException();
}
this.OngenreidChanging(value);
this.SendPropertyChanging();
this._genreid = value;
this.SendPropertyChanged("genreid");
this.OngenreidChanged();
}
}
}
[Column(Storage="_authorized", DbType="Bit NOT NULL")]
public bool authorized
{
get
{
return this._authorized;
}
set
{
if ((this._authorized != value))
{
this.OnauthorizedChanging(value);
this.SendPropertyChanging();
this._authorized = value;
this.SendPropertyChanged("authorized");
this.OnauthorizedChanged();
}
}
}
[Column(Storage="_createdatetime", DbType="DateTime NOT NULL")]
public System.DateTime createdatetime
{
get
{
return this._createdatetime;
}
set
{
if ((this._createdatetime != value))
{
this.OncreatedatetimeChanging(value);
this.SendPropertyChanging();
this._createdatetime = value;
this.SendPropertyChanged("createdatetime");
this.OncreatedatetimeChanged();
}
}
}
[Column(Storage="_updatedatetime", DbType="DateTime NOT NULL")]
public System.DateTime updatedatetime
{
get
{
return this._updatedatetime;
}
set
{
if ((this._updatedatetime != value))
{
this.OnupdatedatetimeChanging(value);
this.SendPropertyChanging();
this._updatedatetime = value;
this.SendPropertyChanged("updatedatetime");
this.OnupdatedatetimeChanged();
}
}
}
[Association(Name="genre_review", Storage="_genre", ThisKey="genreid", OtherKey="id", IsForeignKey=true)]
public genre genre
{
get
{
return this._genre.Entity;
}
set
{
genre previousValue = this._genre.Entity;
if (((previousValue != value)
|| (this._genre.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._genre.Entity = null;
previousValue.reviews.Remove(this);
}
this._genre.Entity = value;
if ((value != null))
{
value.reviews.Add(this);
this._genreid = value.id;
}
else
{
this._genreid = default(int);
}
this.SendPropertyChanged("genre");
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
[Table(Name="dbo.genre")]
public partial class genre : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _id;
private string _name;
private int _sortorder;
private EntitySet<review> _reviews;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnidChanging(int value);
partial void OnidChanged();
partial void OnnameChanging(string value);
partial void OnnameChanged();
partial void OnsortorderChanging(int value);
partial void OnsortorderChanged();
#endregion
public genre()
{
this._reviews = new EntitySet<review>(new Action<review>(this.attach_reviews), new Action<review>(this.detach_reviews));
OnCreated();
}
[Column(Storage="_id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
public int id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
this.OnidChanging(value);
this.SendPropertyChanging();
this._id = value;
this.SendPropertyChanged("id");
this.OnidChanged();
}
}
}
[Column(Storage="_name", DbType="NChar(200) NOT NULL", CanBeNull=false)]
public string name
{
get
{
return this._name;
}
set
{
if ((this._name != value))
{
this.OnnameChanging(value);
this.SendPropertyChanging();
this._name = value;
this.SendPropertyChanged("name");
this.OnnameChanged();
}
}
}
[Column(Storage="_sortorder", DbType="Int NOT NULL")]
public int sortorder
{
get
{
return this._sortorder;
}
set
{
if ((this._sortorder != value))
{
this.OnsortorderChanging(value);
this.SendPropertyChanging();
this._sortorder = value;
this.SendPropertyChanged("sortorder");
this.OnsortorderChanged();
}
}
}
[Association(Name="genre_review", Storage="_reviews", ThisKey="id", OtherKey="genreid")]
public EntitySet<review> reviews
{
get
{
return this._reviews;
}
set
{
this._reviews.Assign(value);
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private void attach_reviews(review entity)
{
this.SendPropertyChanging();
entity.genre = this;
}
private void detach_reviews(review entity)
{
this.SendPropertyChanging();
entity.genre = null;
}
}
}
#pragma warning restore 1591
Thanks in advance.
Thomas
|