boy do I feel stupid. I guess I was trying to do too many things at once.
Anyway, it is still not working. I think it is because I don't have the
northwind example loaded. Why don't I have northwind or pubs databases in my
SQLServer instance?
Thanks,
Siegfried
> boy do I feel stupid. I guess I was trying to do too many things at once.
>
> Anyway, it is still not working. I think it is because I don't have the
> northwind example loaded. Why don't I have northwind or pubs databases in my
> SQLServer instance?
I don't believe it comes with SQL Server 2005 Express. You can get it
here though:
http://blogs.msdn.com/smartclientdata/archive/2005/11/02/488258.aspx

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Siegfried Heintze - 11 Mar 2008 00:52 GMT
It works in Visual Studio 9! How do I write a script to compile and run this
program? See the embedded comments for my attempt.
Thanks,
Siegfried
Error:
Program.cs(2,14): error CS0234: The type or namespace name 'Linq' does not
exist in the namespace 'System' (are you missing an assembly reference?)
Source:
using System;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Collections.Generic;
using System.Text;
/**
* Begin commands to execute this file using MS.NET with CMD.EXE
* csc /out:Program.exe /checked /d:noprompt /debug /r:"c:\Program Files
(x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll"
Program.cs
* Program
* del Program.exe
* del Program.pdb
* End commands to execute this file using MS.NET with CMD.EXE
*/
namespace BasicLINQDemo
{
[Table(Name="Customers")]
class Customer
{
[Column(IsPrimaryKey=true)]
public string CustomerID { get; set; }
[Column]
public string ContactName { get; set; }
[Column]
public string City { get; set; }
}
class Northwind : DataContext
{
public Table<Customer> customers;
public Northwind(String s) : base(s) { }
}
class Program
{
[System.Runtime.InteropServices.DllImport("msvcrt.dll", SetLastError
= true)]
static extern int _getch();
static System.IO.TextWriter outp = System.Console.Out;
static System.IO.TextReader inp = System.Console.In;
static void Main(string[] args)
{
try
{
outp.WriteLine("start BasicLINQDemo");
Northwind db = new Northwind(".");
var query = db.customers;
foreach (Customer c in query)
outp.WriteLine(c.ContactName + ", " + c.City);
}
finally
{
#if noprompt
outp.WriteLine("terminating props.cs");
#else
outp.Write("Enter any key to exit BasicLINQDemo.cs: ");
_getch();
#endif
}
}
}
}