Last post Sep 05, 2006 09:26 PM by synced
Aug 21, 2006 01:44 PM|synced|LINK
I'm going to give this another shot. I really hope someone can help me out and point out where my mistake is.
My understanding is LINQ/DLINQ and BLINQ is supposed to make querying data much simpler and using this data much simpler as well.
So I am trying to create a webservice, of which I can use DLINQ to make a query, and use the objects BLINQ generated for easy use. My webservice code is wrong but I can't get anyone in the DLINQ forum to point out whats wrong with it.
Any help would be greatly appreciated.
Basically once the webservice returns a collection of objects I want to bind it to the datasource of a GridView. I believe I can do that in the Atlas OnComplete callback but I am not even at that point yet as the Webservice crashes.
Here is the code:
public Domain Search(string searchText)
MyDomains db = MyDomains.CreateDataContext();
obj = (from dom in db.Domains
I don't know if I've implemented this right, but the compiler is stating:
Error 1 'System.Data.DLinq.Table<Domain>' does not contain a definition for 'ToArray'
So I believe my biggest issue is, what do I set the return type as for the webservice. Someone in DLINQ forum said ToArray but that doesn't exist. I tried list, etc but I get errors on runtime about circular references.
Could anyone please help? All the BLINQ generated stuff works great but how do I add my own queries that return different data?
I really want to build ontop of BLINQ and evaluate it as our next web platform for our company for when LINQ/DLINQ/BLINQ goes final but I've been stuck on this issue for >1 week. I feel very silly as all I read is how simple things should be but obviously
I have done something wrong.
Please help me understand :)
Thanks and take care.
Aug 22, 2006 01:30 PM|synced|LINK
Anyone? please? If this stuff doesn't work in the current CTP that is fine. I am trying to do something pretty common place I would think. I know I have done it wrong I just don't know where. I've tried various return types with no such luck.
Please a little guidance where my error is would be highly appreciated.
Aug 23, 2006 06:51 PM|synced|LINK
Aug 23, 2006 07:02 PM|phuff|LINK
Aug 23, 2006 08:32 PM|synced|LINK
Thank you so much Polita!
I just wan't sure if this is something not known yet or just nobody fealt like responding.
I have some questions for you which may be able to help me figure out what the issue is.
I think my problem is the return type.
Someone in the LINQ forum mentioned that you need to use System.Data.Extensions.dll so you can ToArray() the LINQ query and you return the array from your webservice.
Unfortunately they are saying System.Data.Extensions.Dll does not work in website model, only in web application model.
As far as I know BLINQ generates a project in Website model correct? I really don't know much about this stuff but if we are able to piece it together I would love to throw a blog post up somewhere about it.
Thanks and take care!
Aug 23, 2006 08:52 PM|phuff|LINK
This, I think I can answer!
If the ToArray() extension method is defined in System.Data.Extensions.dll, you should be able to add that binary to your Bin folder, include it in the compiler options specified in the web.config file, add it as a "using" statement to your .cs file (or
as an import to your .vb file), and you'll be good to go. Give it a try.
I think what the LINQ team was saying is that the LINQ Web template they shipped with the May preview supports only the web app model and not the website model. However, since you're using a Blinq app (which uses the website model) you are not using their
template. You should be able to make this work in your app.
In the end, the compiler and linker don't know anything about whether it's a website or a web application. It's just a set of files that get compiled together to build a library. So if something compiles in one model, there is probably a way to make it
compile in the other model.
Aug 23, 2006 10:24 PM|synced|LINK
I think this is where my experience starts to run a little thin so may need to request some of your expertise :)
So I am assuming I need to add a similiar line to:
Correct? So I would make an entry with System.Data.Extensions.dll
I have done this, and I tried to use sn -T to find the PublicKeyToken for System.Data.Extensions.dll and it does not work.
So I left out the PublicKeyToken and I still get the following error on my "using" clause:
Error 20 The type or namespace name 'Extensions' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Any guidance would be great :)
Aug 23, 2006 10:43 PM|phuff|LINK
It looks to me like System.Data.Extensions.dll is already in the Bin folder.
However, I looked up the ToArray(IEnumerable<T>) extension method and it looks to me like it's in System.Query.dll in the System.Query namespace. This means all you should need is a using statement for System.Query. Your StaticMethods file should already
have this in it. If you try to use this method in you StaticMethods file, does it compile and work correctly?
Aug 24, 2006 01:47 PM|synced|LINK
Thanks so much for the help Polita. I feel like such a dumbass. Apparently I was missing System.Data in my using clause. VS wasn't giving much of a useful error to figuring this out, oh well my mistake!
So now I am in a serialization pickle I think. The following code causes the following exception when the WebService is tested:
MyDomains db = MyDomains.CreateDataContext();
var domains = from dom
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: A circular reference was detected while serializing an object of type Domain.
at System.Xml.Serialization.XmlSerializationWriter.WriteStartElement(String name, String ns, Object o, Boolean writePrefixed, XmlSerializerNamespaces xmlns)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write5_Domain(String n, String ns, Domain o, Boolean isNullable, Boolean needType)
So I've tried returning Domain I've tried returning Table<Domain> still get this serialization error.
You might know since you wrote GridView though :) GridView rocks btw!
Aug 25, 2006 01:09 PM|synced|LINK
Based on the above. Any thoughts of what I could return from my webservice that would be serializable that I can set GridView's datasource to?
Aug 25, 2006 06:00 PM|phuff|LINK
Well, the first thing that comes to mind is that a DataContext might not be serializable. I talked to the LINQ team about "tear offs", or serializability, and they agreed that it was a scenario but didn't have time to make it work in the May LINQ Preview.
The best place to get information on DataContext serializability is the
LINQ forum. The LINQ team monitors it and will answer questions and take requests for features.
Sorry I can't help you more. I hope the LINQ team can help.
Aug 27, 2006 06:46 PM|rtortima|LINK
I have been following DLinq/BLinq dev evolution. AFAIK, its not intended to work natively with Oracle, MySql or other DB but SqlServer. Is it true?
So after releasing the final version (any idea when it would be?), will it be others providers job to make this link between Linq and DB tech?
Aug 28, 2006 04:50 PM|synced|LINK
Hope you had a good weekend!
Thanks for the reply Polita.
I can understand not everything works yet in the CTP's, that is fine.
I also have some questions as I have been previewing a lot of the CTP's as of lately. We are a web shop deciding if we want to switch to ASP.NET and these CTP's are giving us great insight into if we will make the switch or not.
From what I understand BLINQ does 2 things:
1. Created classes that are bound to your DB so you can use OO for data access
2. Auto-generate listing/insert/update/delete pages based off all of the generated classes in #1.
So I have been starting to take a look at ADO.NET vNext CTP. What I am concerned is having seperate data layers half being the auto-generated BLINQ ones, and then using ADO.NET vNext for other things. Is it possible later versions of BLINQ will be using
vNext for its objects rather than custom codegen classes?
I really like the wizards ADO.NET vNext has, but I also really like what BLINQ has to offer with auto-generated pages. I really don't want to have 2 seperate OO data layers to work with on one site.
Any insight on what the future holds would be great for our understanding of how things piece together. We have no problem waiting for things to mesh together in the CTP's but any insight on how all the pieces relate would be great.
So far ASP.NET's new technology CTP's have us very interested, great work :)
Aug 29, 2006 12:34 AM|phuff|LINK
The May LINQ Preview supports only SQL Server. However, other providers will be supported when LINQ is released.
Sep 05, 2006 07:56 PM|synced|LINK
Can you please comment on my questions above? I am still concerned about having 2 branches of my data model created as objects for me and dealing with 2 API etc.
Sep 05, 2006 08:11 PM|phuff|LINK
Sep 05, 2006 09:26 PM|synced|LINK
Hmm I see. I thought ADO.NET vNext was an actual product update? I just sort of see a bit of overlap where both ADO.NET vNext and BLINQ generate objects to access your DB. So if I am going to use BLINQ along with the next iteration of ADO.NET then I am
going to have 2 seperate versions of my DB generated into classes, with different API.
Honestly feel that I am getting confused by Microsoft blurring the lines too much. I love the power BLINQ has for auto-generating pages, but both BLINQ and ADO.NET vNext generate an object structure of your DB and if some components use ADO.NET vNext, and
BLINQ doesn't use ADO.NET vNext objects, then I am basically forced to use both. Which seems like overkill to me.
It could be I am just confused as well, very possible :) I am just concerned of having my DB generated twice and using 2 seperate API etc. Very confusing!
Thanks for all your help throughout.