Oh, that's a great idea, and indeed - it works :)
I already managed to do the .DayOfWeek things in the iteration loop, but
your solution is much smarter than this.
Great.
Yes, Linq-to-SQL does work on SQL CE perfectly. But it doesn't work
automatically. You have to manually "SQL-metalize" the database, whenever
you change the table layout. There is a couple of blogs out, describing this
issue. The tool "sqlmetal.exe", required for this, is available in the SDK.
(Program Files\Microsoft SDKs\Windows\v6.0A\bin)
In my case I always run
SqlMetal.exe Database.sdf /dbml:KS.dbml /namespace:KS /pluralize
This produces KS.dbml, which I import into my project every time it is
changed (delete/add). The KS.designer.cs then contains all the classes
required for nice and smart "CRUDs". Because the structure of my db doesn't
change that frequently I can live with this small manual interaction.
I never worked with a SQL database easier.
Regards and thanks again for your assistance
Neil.
"Marc Gravell" <ma**********@gmail.comschrieb im Newsbeitrag
news:7d**********************************@l42g2000 hsc.googlegroups.com...
Intersting... I didn't know that @@DATEFIRST didn't work on SQL CE,
but then - I didn't know that LINQ-to-SQL *did* work on SQL CE ;-p
You could perhaps try just selecting the date (o.Date) from the
database (perhaps calling ToList() or ToArray() to buffer it locally),
then do a second projection afterwards?
var tmp = context.Absences.OrderBy(o =o.Date).Select(o =new {
o.Department, o.Name, o.Date, o.Reason }).ToArray();
var absenses = tmp.Select(o =new {
o.Department, o.Name, o.Date.Month, o.Date.DayOfWeek,
o.Reason });
That might fix it?
Marc