score:2

Accepted answer

look at the end of the form1.cs source file, the linq to sql database is declared using attributes:

[database(name = "adventureworks")]
public class adventureworks : datacontext
{
    //public table<dirinfo> directoryinformation;
    public adventureworks(string connection) : base(connection) { }
    public table<directoryinformation> directoryinformation;
}

[table(name = "directoryinformation")]
public class directoryinformation
{
    [column(dbtype="varchar(50)")]
    public string directoryname;

    [column(dbtype = "varchar(255)")]
    public string directorydescription;
}

providing the settings with the project define a connection string, this is all you need for a simple mapping of the directoryinformation type to the directoryinformation table in the adventureworks database.

score:1

oh, absolutely you can use vanilla objects with linq-to-sql; you don't even need to subclass datacontext - but you do need to tell it about your model. this is often done with attributes on members (for columns) and types (for tables), but can also be done with an external mapping file (xml). i wonder if they are just over-abbreviating for simplicity... for example, i suspect that the table should be a property:

public table<directoryinformation> directoryinformation {
    get { return gettable<directoryinformation>(); }
}

the whole "dbml" thing is just there as a designer tool to help you generate the classes; the important code is just decoracted classes (with some conventions on things like navigation properties to make life simper to use). that said, for "quickest": use the designer.


Related Query

More Query from same tag