On Mon, 2010-09-20 at 11:09 -0700, El wrote:
> I have a sqlite 3 database call MySampleDB.sq3.
Q1: what is the schema for this database?
> I use sqlmetal to generate the MySampleDB.cs file as
> follows:
>
> $ sqlmetal /provider:Sqlite /conn "Data Source=./MySampleDB.sq3" /
> code:MySampleDB.cs
Q2: What is generated from this command?
> Then I moved the generated cs code to the project directory and added
> this file to my project in MonoDevelop.
>
> I edited the file to rename all "Main" in the MySampleDB.cs to be
> MySampleDB is avert confusion with my Main() class.
You shouldn't have a Main class anyway for your program entrypoint, as
Main() is the name of the program entrypoint method, and Main.Main()
would be a constructor. That way lies madness. ;-)
Meanwhile, you can have a Main type and a Foo.Main() method without
naming collision.
Finally, you can use `sqlmetal --database=MySampleDB ...` to cause
sqlmetal to generate a DataContext subclass with the name MySampleDb.
> In my Main.cs on the project, which is a console type project, I
> created the following code:
>
> using System;
> using System.Data;
> using Mono.Data.SqliteClient;
> using System.Linq;
> using DBLinq;
>
> namespace sqlinqtest
> {
> class MainCLass
> {
> public static void Main(string[] args)
> {
> linqtestcode();
> }
>
> private static void linqstylecode()
> {
> IDbConnection dbcon;
> dbcon = (IDbConnection) new SqliteConnection(
> "DBLinqProvider=Sqlite; DataSource=./
> MySampleDB.sq3" // per other blog, does not require
>
> //
> DbLinqDataTypeProvider if pass
This is probably a casing issue, as it should be DbLinqProvider, not
DBLinqProvider (note that 'b' should be lowercase).
You're also mentioning some blog, but not the URL for said blog, which
could provide additional context.
//
> So the problem I'm having is that the table column definitions in the
> query is not visible and obviously I get an error at compile saying
> that "Type 'User' does not contain the definition for 'uid' and no
> extension method 'uid' of type 'User' could be found", suggesting that
> I may have a missing "using" directive or a missing assembly
> reference.
No, it implies that db.User is returning a User type, which is found,
but the property reference 'u.uid' cannot be found. Based on your
sqlmetal invocation, this is likely because sqlmetal is PascalCasing
your column names, and thus it should be u.Uid and u.Name (as opposed to
u.uid and u.name).
You can use the /case:leave option to partially disable this behavior.
Again, viewing the generated C# source would be helpful here [Q2].
- Jon
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en.