New question on Linq To Sql

When I do it manually

public class AdventureWorks : DataContext
{
    public AdventureWorks(string connection) : base(connection) { }
    public Table<Contact> Contacts;
}

[Table(Name = "Person.Contact")]
public class Contact
{

    [Column(DbType = "int not null", IsPrimaryKey = true, IsDbGenerated = true)]
    public int ContactID;

    [Column(DbType = "nvarchar(8) not null")]
    public string Title;

    [Column(DbType = "nvarchar(50) not null")]
    public string FirstName;

    [Column(DbType = "nvarchar(50) not null")]
    public string MiddleName;

    [Column(DbType = "nvarchar(50) not null")]
    public string LastName;

    [Column(DbType = "nvarchar(50) not null")]
    public string EmailAddress;

    [Column(DbType = "int")]
    public int EmailPromotion;

    [Column(DbType = "bit")]
    public byte NameStyle;

    [Column(DbType = "varchar(40)")]
    public string PasswordHash;

    [Column(DbType = "varchar(40)")]
    public string PasswordSalt;

}

      

I can use something like this

AdventureWorks db = new AdventureWorks("Integrated Security=sspi");
Contact cont = db.Contacts.Single(c => c.ContactID == 1280);

      

But if I rely on LINQ surface (designer) drag and drop contacts table into dbml file, I can see db.Contacts but can't see "db.Contacts.Single" method.

Is there anything to do with the dbml property configuration?

Please advise.

Many thanks.

+1


source to share


1 answer


Are you using these two namespaces?



using System.Data.Linq;
using System.Linq;

      

+4


source







All Articles