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:
[WebMethod]
public Domain[] Search(string searchText)
{
MyDomains db = MyDomains.CreateDataContext();
Domain[] obj;
obj = (from dom in db.Domains
select dom).ToArray<Domain>();
return obj;
}
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.
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.
Ok well I am really sorry for complaining here but is this something just not possible with the current CTP? If it is not then I would rather know ahead of time instead of continiously banging my head here and wait for another CTP.
Synced, I'm sorry that I don't have any answers for you here. I don't know if LINQ works over a web service or whether LINQ object will serialize correctly. You're using 3 relatively-independent unreleased technologies together, so I would expect some hitches,
but if you do get this working, please post here so others can learn from the cool stuff you're doing.
Polita Paulus
This posting is provided "AS IS" with no warranties, and confers no rights.
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.
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.
Polita Paulus
This posting is provided "AS IS" with no warranties, and confers no rights.
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?)
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?
Polita Paulus
This posting is provided "AS IS" with no warranties, and confers no rights.
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
in db.Domains
select dom;
return domains;
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.
Perhaps I need to create a datasource in the WebService then return the actual Datasource. But I am not sure if I can serialize datasources or not and then set them dynamically to the GridView via javascript.
You might know since you wrote GridView though :) GridView rocks btw!
synced
Member
132 Points
45 Posts
BLINQ and Atlas
Aug 21, 2006 01:44 PM|LINK
Hey gang.
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:
[WebMethod]
public Domain[] Search(string searchText)
{
MyDomains db = MyDomains.CreateDataContext();
Domain[] obj;
obj = (from dom in db.Domains
select dom).ToArray<Domain>();
return obj;
}
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.
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
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.
Thanks and take care.
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
Aug 23, 2006 06:51 PM|LINK
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: BLINQ and Atlas
Aug 23, 2006 07:02 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
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!
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: BLINQ and Atlas
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.
This posting is provided "AS IS" with no warranties, and confers no rights.
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
Aug 23, 2006 10:24 PM|LINK
Thanks Polita!
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:
<
add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>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 :)
Thanks!
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: BLINQ and Atlas
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?
This posting is provided "AS IS" with no warranties, and confers no rights.
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
Aug 24, 2006 01:47 PM|LINK
Good morning!
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 in db.Domains
select dom;
return domains;
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.
Perhaps I need to create a datasource in the WebService then return the actual Datasource. But I am not sure if I can serialize datasources or not and then set them dynamically to the GridView via javascript.
You might know since you wrote GridView though :) GridView rocks btw!
synced
Member
132 Points
45 Posts
Re: BLINQ and Atlas
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?
Thanks and take care.