dblinq integration testing

20 views
Skip to first unread message

Atsushi Eno

unread,
Aug 14, 2008, 1:32:06 AM8/14/08
to mono-s...@googlegroups.com
Hello,

I have cooked a hacky dblinq integration to mcs tree. It's almost
just a manual copy of sources from trunk and *.dll.sources hack.
Not an ideal way of doing it, but it was like an hour of hack.

The following URL is a link to the archive of System.Data.Linq
directory that is to put under (mcs_topdir)/class directory:
http://veritas-vos-liberabit.com/tmp/2008/0814/System.Data.Linq.tar.bz2

I also put README there, in case you wonder what to do.

Pablo, if you have some runnable samples, can you cook some
instruction on how to run them so that we can try your effort out?
It would also be important for GSoC evaluators (not memtors, in
this case).

Atsushi Eno

Pablo Iñigo Blasco

unread,
Aug 14, 2008, 6:02:57 AM8/14/08
to mono-s...@googlegroups.com
On Thu, Aug 14, 2008 at 7:32 AM, Atsushi Eno <ats...@ximian.com> wrote:

Hello,

I have cooked a hacky dblinq integration to mcs tree. It's almost
just a manual copy of sources from trunk and *.dll.sources hack.
Not an ideal way of doing it, but it was like an hour of hack.
 
Great.


The following URL is a link to the archive of System.Data.Linq
directory that is to put under (mcs_topdir)/class directory:
http://veritas-vos-liberabit.com/tmp/2008/0814/System.Data.Linq.tar.bz2

I also put README there, in case you wonder what to do.
 
Thank you, let me build and test it over mono.

Pablo, if you have some runnable samples, can you cook some
instruction on how to run them so that we can try your effort out?

We have runnable samples: our tests. Nonetheless I'm going to build a little program for testing s.d.linq on Mono, after this I'll send it to you. Anyway if you want build your own sample:
- The first thing we need is a database (better if it is SqlServerExpress but SqlServer is also ok).
- Extract the schema using sqlmetal (The Microsoft's command tool) and you'll get an autogenerated cs file.
- And that's all you can use the generated classes, you only have to pass the connection-string to the DataContext constructor.

Regards the readme file:

 I made some API fixes to fix build. Some sources in sugar were missing

MONO_STRICT switch, and marked as public:
    GroupByExpression.cs
    ScopeExpression.cs

AFAIK such classes are obsoletes (ie:GroupByExpression has been replaced by GroupExpression ), maybe they are oldengine's classes, there are no references to them in the whole project. They aren't included in DbLinq.csproj too.

Regards the build of the tarball, excuse me about my clumsiness:
I tried to run "make POFILE=net_2_0" and I got:

Makefile:3: ../../build/rules.make: No such file or directory
Makefile:29: ../../build/library.make: No such file or directory
make: *** No rule to make target `../../build/library.make'.  Stop.

After I tried to do it manually:

gmcs.exe /codepage:65001  -optimize -d:NET_1_1 -d:NET_2_0 -debug /noconfig /r:System.dll /r:System.Core.dll /r:System.Xml.dll /r:System.Data.dll /d:MONO_STRICT -d:NET_3_5 -nowarn:1720 -target:library -out:../../class/lib/net_2_0/System.Data.Linq.dll  @System.Data.Linq.dll.sources

DbLinq/Data/Linq/Implementation/MemberModificationHandler.cs(189,61): error CS0246: The type or namespace name `PropertyChangingEventArgs' could not be found. Are you missing a using directive or an assembly reference?

Compilation failed: 1 error(s), 0 warnings

 
So I moved the project to the mcs/class/System.Data.Linq foder and I got the System.Data.Linq.dll  but executing all the mono build, Is it the correct way? (it failed on the signing stage however the assembly was in mcs/class/lib/net_2_0)

Regards.



Atsushi Eno

unread,
Aug 14, 2008, 1:45:07 PM8/14/08
to mono-s...@googlegroups.com
Hey,

Pablo Iñigo Blasco wrote:
> I made some API fixes to fix build. Some sources in sugar were missing
>
> MONO_STRICT switch, and marked as public:
> GroupByExpression.cs
> ScopeExpression.cs
>
>
> AFAIK such classes are obsoletes (ie:GroupByExpression has been replaced
> by GroupExpression ), maybe they are oldengine's classes, there are no
> references to them in the whole project. They aren't included in
> DbLinq.csproj too.

OK, just verified that they do not exist in .csproj.

> Regards the build of the tarball, excuse me about my clumsiness:
> I tried to run "make POFILE=net_2_0" and I got:
>
> Makefile:3: ../../build/rules.make: No such file or directory
>
> Makefile:29: ../../build/library.make: No such file or directory
>
> make: *** No rule to make target `../../build/library.make'. Stop.
>
>
> After I tried to do it manually:
>
> gmcs.exe /codepage:65001 -optimize -d:NET_1_1 -d:NET_2_0 -debug
> /noconfig /r:System.dll /r:System.Core.dll /r:System.Xml.dll
> /r:System.Data.dll /d:MONO_STRICT -d:NET_3_5 -nowarn:1720
> -target:library -out:../../class/lib/net_2_0/System.Data.Linq.dll
> @System.Data.Linq.dll.sources
>
> DbLinq/Data/Linq/Implementation/MemberModificationHandler.cs(189,61):
> error CS0246: The type or namespace name `PropertyChangingEventArgs'
> could not be found. Are you missing a using directive or an assembly
> reference?
>
> Compilation failed: 1 error(s), 0 warnings
>
>
>
> So I moved the project to the mcs/class/System.Data.Linq foder and I got
> the System.Data.Linq.dll but executing all the mono build, Is it the
> correct way? (it failed on the signing stage however the assembly was in
> mcs/class/lib/net_2_0)

Yes, that's the only way to build our class libs (move there and
run make PROFILE=*), except for that assembly key problem. We may
need different AssemblyInfo.cs in our tree, apart from the one in
.csproj. It depends on the build tree layout and build platforms.

Atsushi Eno

Pablo Iñigo Blasco

unread,
Aug 15, 2008, 3:34:03 PM8/15/08
to mono-s...@googlegroups.com
Hi


On Thu, Aug 14, 2008 at 7:32 AM, Atsushi Eno <ats...@ximian.com> wrote:
Pablo, if you have some runnable samples, can you cook some
instruction on how to run them so that we can try your effort out?
It would also be important for GSoC evaluators (not memtors, in
this case).


I have attached the following resources:
- A sql script for generating a schema in a sqlserverExpress database needed for running the sample in your machine
- The example csharp file (Test.cs), this example shows a varied set of features already implemented in System.Data.Linq
- The auto-generated Datacontext csharp file(using sqlmetal.exe) from such database schema.
- An output text file of the results using MS/.Net and Linq2Sql in windows.
- An  output text file of results using Mono and our System.Data.Linq.dll namespace in Linux
- An assembly of our System.Data.Linq.dll (compiled with csc)
- An assembly of our System.Data.Linq.dll (compile with gmcs, there is a problem explained at the end of this mail)
- A modified assembly of Mono.Data.Tds.dll (since I had some problems with the connection string in the working sample) and a patch explaining the change
- A folder with information about those problems.

The working sample is the following :

   Console.WriteLine("OS:" + System.Environment.OSVersion + ", Environment.Version:" + System.Environment.Version.Build);
            IDbConnection conn = new System.Data.SqlClient.SqlConnection("Data Source=192.168.1.61\\SQLEXPRESS,1154;Integrated Security=False;Initial Catalog=Northwind;User Id=dblinqUser;Password=linq2");
            conn.Open();
            Console.WriteLine(conn.State);

            Northwind nwindDb = new Northwind(conn);

            //simple scalar query
            Console.WriteLine("Number of Employees:" + nwindDb.Customers.Count());


            //filter + orderby
            var customers = nwindDb.Customers.Where(e => e.Orders.Any())
                                            .OrderByDescending(c => c.CustomerID)
                                            .ToList();

            foreach (var a in customers)
            {
                Console.WriteLine("Customer '{0}':", a.CustomerID);

                //anonymous projections
                var customerOrdersInfo = a.Orders.Select(o => new { o, o.ShipAddress });
                Console.WriteLine("\tNumber of pending orders:" + a.Orders.Count);

                //entitySet access
                if (a.Orders.Any())
                {
                    foreach (var orderInfo in customerOrdersInfo)
                    {
                        Console.WriteLine("\t·order: {0}", orderInfo.o.OrderID);
                        if (!string.IsNullOrEmpty(orderInfo.o.ShipAddress))
                            Console.WriteLine("\tIt should be sent to: {0} {1} {2}", orderInfo.ShipAddress, orderInfo.o.ShipCity, orderInfo.o.ShipCountry);
                    };

                }
                Console.WriteLine();
            }

            //more complex scalar query
            bool d = nwindDb.Orders.Any(o => o.Customer.ContactName == "WARTH");
            Console.WriteLine();
            Console.WriteLine("Are there any order for WARTH? " + (d ? "yes" : "no").ToString());
            Console.WriteLine();


            //anonymous projection+ filter query + orderby
            var q = (from e in nwindDb.Employees
                     where e.Orders.Any(o => o.Customer.CustomerID == "AIRBU" || o.Customer.CustomerID == "BONAP")
                     orderby e.FirstName
                     select new { Name = e.FirstName + "," + e.LastName, e.HomePhone }).ToList();


            foreach (var emp in q)
                Console.WriteLine(emp.Name + ", Phone:" + emp.HomePhone);


            //strings operations
            var shortphones = nwindDb.Customers.Where(c => (c.CustomerID.Trim().Contains("T") || c.Country == "France"))
                                       .Select(z => new { z.Phone, Name = z.CustomerID.ToLower() });

            foreach (var shortphone in shortphones)
                if (shortphone != null)
                    Console.WriteLine(shortphone.Name + ":" + shortphone.Phone);

            Customer newCust = nwindDb.Customers.FirstOrDefault(x => x.CustomerID == "PAUL");
            if (newCust != null)
            {
                //write/delete
                Console.WriteLine("customer 'PAUL' already exists, removing...");
                nwindDb.Customers.DeleteOnSubmit(newCust);
                nwindDb.SubmitChanges();
                Console.WriteLine("done");
            }

           
            Console.WriteLine("Checking if Paul is in the database");
            newCust = nwindDb.Customers.FirstOrDefault(x => x.CustomerID == "PAUL");
            if (newCust != null)
                Console.WriteLine("Paul is in the database");
            else
                Console.WriteLine("Paul is not in the database");

            //write/insert
            Console.WriteLine("Inserting new customer..");
            newCust = new Customer { CustomerID = "PAUL", City = "Seville", Country = "Spain" ,CompanyName="Mono"};
            nwindDb.Customers.InsertOnSubmit(newCust);
            nwindDb.SubmitChanges();
            Console.WriteLine("done");

           
            newCust = nwindDb.Customers.FirstOrDefault(x => x.CustomerID == "PAUL");
            if (newCust != null)
            {
                Console.WriteLine("Paul is in the database");
                Console.WriteLine("{0} {1} {2}", newCust.CustomerID, newCust.City, newCust.Country);
            }
            else
                Console.WriteLine("Paul is not in the database");


Problems:
- Our System.Data.Linq.dll compiled using gmcs don't work properly, it initially begin working properly the sample but after I get a BadImageFormatException. Both System.Data.Linq.dll assemblies and the error stacktrace are inside of the "Problems folder".I have tried to build again such assembly and I got the same problem.
- Also I have changed a couple of things in Mono.Data.Tds.Protocol.TdsComm to run this sample  (patch attached) it failed with a connection string like this(Data Source=192.168.1.61\\SqlServer,1154;Integrated Security=False;Initial Catalog=Northwind;User Id=dblinqUser;Password=linq2). It is related with: http://lists.ximian.com/pipermail/mono-bugs/2008-July/076551.html. Nonetheless such patch has a problem, it uses the full DataSource field to try parse the ip, in this case it is a wrong behaviour
- This example works properly because it has been built for work properly, however there're still many bugs and not implemented features, so there are a lot of work to do in System.Data.Linq.dll yet and IMO we'll have to wait a few months for getting a more stable version. I will continue contributing in this namespace for achieving this objective.


Regards.


sdlinqWorkingSample.rar
Reply all
Reply to author
Forward
0 new messages