Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 05, 2006 09:26 PM by synced
Aug 21, 2006 01:44 PM|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|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|LINK
Aug 23, 2006 07:02 PM|LINK
Aug 23, 2006 08:32 PM|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|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|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|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|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|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?