Code: Select all
CREATE TABLE [dbo].[Test](
[TestID] [int] IDENTITY(1000,1) NOT NULL,
[PrimaryKey] AS ([TestID]),
[Code] [varchar](50) NULL,
CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED
(
[TestID] ASC
)ON [PRIMARY])
GO
INSERT INTO Test(code)
SELECT 'test'
Code: Select all
IQueryable<Test> tester = sc.DB.Test.Where(p => p.Code == "test");
List<int?> accs = tester.Select(p => (int?)p.PrimaryKey).ToList();
Code: Select all
List<int?> accs = tester.Select(p => (int?)p.TestID).ToList();
This is the definition
Code: Select all
[Table(Name = @"dbo.Test")]
public partial class Test : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(System.String.Empty);
#pragma warning disable 0649
private int _TestID;
private int _PrimaryKey;
private string _Code;
#pragma warning restore 0649
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(ChangeAction action);
partial void OnCreated();
partial void OnTestIDChanging(int value);
partial void OnTestIDChanged();
partial void OnPrimaryKeyChanging(int value);
partial void OnPrimaryKeyChanged();
partial void OnCodeChanging(string value);
partial void OnCodeChanged();
#endregion
public Test()
{
OnCreated();
}
/// <summary>
/// There are no comments for TestID in the schema.
/// </summary>
[Column(Storage = "_TestID", AutoSync = AutoSync.OnInsert, CanBeNull = false, DbType = "INT NOT NULL IDENTITY", IsDbGenerated = true, IsPrimaryKey = true)]
public int TestID
{
get
{
return this._TestID;
}
set
{
if (this._TestID != value)
{
this.OnTestIDChanging(value);
this.SendPropertyChanging("TestID");
this._TestID = value;
this.SendPropertyChanged("TestID");
this.OnTestIDChanged();
}
}
}
/// <summary>
/// There are no comments for PrimaryKey in the schema.
/// </summary>
[Column(Storage = "_PrimaryKey", AutoSync = AutoSync.Always, CanBeNull = false, DbType = "INT NOT NULL", IsDbGenerated = true, UpdateCheck = UpdateCheck.Never)]
public int PrimaryKey
{
get
{
return this._PrimaryKey;
}
set
{
if (this._PrimaryKey != value)
{
this.OnPrimaryKeyChanging(value);
this.SendPropertyChanging("PrimaryKey");
this._PrimaryKey = value;
this.SendPropertyChanged("PrimaryKey");
this.OnPrimaryKeyChanged();
}
}
}
/// <summary>
/// There are no comments for Code in the schema.
/// </summary>
[Column(Storage = "_Code", DbType = "VARCHAR(50)", UpdateCheck = UpdateCheck.Never)]
public string Code
{
get
{
return this._Code;
}
set
{
if (this._Code != value)
{
this.OnCodeChanging(value);
this.SendPropertyChanging("Code");
this._Code = value;
this.SendPropertyChanged("Code");
this.OnCodeChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
var handler = this.PropertyChanging;
if (handler != null)
handler(this, emptyChangingEventArgs);
}
protected virtual void SendPropertyChanging(System.String propertyName)
{
var handler = this.PropertyChanging;
if (handler != null)
handler(this, new PropertyChangingEventArgs(propertyName));
}
protected virtual void SendPropertyChanged(System.String propertyName)
{
var handler = this.PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
}