Hi Alex, I was moved this discussion here. My model is the following:
When the domain is built, DO creates the intermediate table as you know. I have the following LINQ Query to query all the doctors that belong to an specific speciality:
The line where starts the exception is: for (var r in list) The message exception is: {"Invalid TupleDescriptor. Expected descriptor is TupleDescriptor(Int32, Int32, String, Boolean).\r\nParameter name: difference"} The stacktrace is the following:
I see that the tuple descriptor belongs to the Doctor Entity definition, but my goal is to obtain the following output: Speciality Doctor Email Ophthalmology Francisco Correa fran@gmail.com Ophthalmology Alex Yakunin alex@gmail.com Thanks in advance. Updated at 03.06.2010 20:22:55Ok, sorry Alex, instead of Specialities must be Speciality in the following piece of code, only I was forgotten, because in my original model there is:
Ok, I'm going to try with your code and I'm going to tell you if everything works. Thanks in advance Updated at 04.06.2010 1:31:23Always the same exception... Can I obtain in a concatenated string variable without using the line of code "foreach (var item in list)"? Because in this line of code there is the exception. The bold part can I concatenate or necessarily I must use "foreach (var item in list)"?
Thanks in advance. Updated at 08.06.2010 3:22:02First, I have a Windows Service where I use DataObjects. I have a socket server implementation inside them, and I have some operations that I call with a socket client that I have programmed in the socket server. All the operations until now work well, except an operation that relates Speciality and Doctor entities. As you know early we made a LINQ query that list all the doctors that belong to an specific Speciality. The following code makes that:
Trying to obtain the output result, I have the following piece of code:
Assuming the definition of the Doctor Entity and Speciality, I have the following:
I have observed that the exception: {"Invalid TupleDescriptor. Expected descriptor is TupleDescriptor(Int32, Int32, String, Boolean).\r\nParameter name: difference"} relates to the Doctor entity definition, because assuming the data types parameters is the same to the Doctor entity columns, except by the second parameter that belongs the TypeId property that correspond to the DataObjects.net implementation. Really I dont know why I received this exception. Alex if you need more clarification,just tell me.I hope it is understood. Sorry for my poor english. Thanks in advance. Updated at 08.06.2010 13:46:59Hello Dmitri, I have already this error fixed (Speciality instead of Specialities). The problem is not that. Hello psulek, just I have omitted the HierarchyRoot attribute here, but I have in my model, sorry I have forgotten. The following LINQ query that you showed me I have already tested:
And the same for the following code:
I did not add Speciality or Doctor like that, because I have stored already in the tables:
Thanks in advance. Updated at 24.06.2010 3:39:07Ok, I have two solution, a socket server project and a client socket project, there are three projects in the socket server project: 1) A Class Library named "Aspectos", here there are classes that have some aspects using PostSharp like attributes. 2) Another Class Library named "OperacionesSocketServer", here there is the Model of the database and the list of the operations of the socket server. 3) A Socket Server itself using a Windows Service template. The problem is HOW CAN I WRITE THE LINQ QUERY If you test the operations you are going to see all work but the operation VME is the problem. Obs: My main language is spanish, there is difference in the names of the Entities, etc. for example Specialities is Especialidades and Doctors is Medicos. Here are the files [attachment=1:371mhmby]TestingAspects.rar[/attachment:371mhmby] [attachment=0:371mhmby]SocketAsyncClient.rar[/attachment:371mhmby] Updated at 06.07.2010 1:50:34No, the problem is not the serialization, because I do not pass the LINQ query between client and server. If you could download the code and test you may see which is the error. The error itself is the LINQ query, relationship between the type of one or more of the fields of the entities. Try to test please, because I was tried many times but without success. Thanks in advance. Updated at 08.07.2010 1:39:29I understand you Alex, I have already read the manual, but is not precise, specially because I have two entities and the relationship is many to many and I need a simple LINQ Query that solve my requirements, I saw that in the manual there is an example, but when I test with my application does not work and the exception appears.
If you see, the problem seems very simple, but until now I can't resolved. I bellieve that my entities definition Speciality and Doctor are correct. This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by DiegoCorrea. |
Alex (Xtensive) wrote:It seems there is a bug in Domain model builder allowing you to use [Association(PairTo = ...)] on both sides of relationship - that's wrong, this attribute must be used only on one side. The side it is applied to becomes "virtual": no data structures are created for it, it relies on structures created for another side instead. Try to fix this issue first. I'll create a bug report about this. Btw, I think you must switch from using "Doctors" and "Specialities" to "Doctor" and "Speciality". Plural class names are quite untypical in .NET world. Alex (Xtensive) wrote:Ok, I just implemented everything in test. Conclusions: 1) Bug in code you've provided: for (var r in list) ... doesn't compile - by obvious reason. 2) Absence of [HierarchyRoot] at your types was leading to this exception:
3) Bug with [PairTo] was actually a "feature" - i.e. everything was ok if you declare pairing on both sides. I added the following check: if multiplicity is one-to-one or many-to-many, an exception will be thrown, since in this case it's impossible to determine which side of relationship must be "virtual". Before this new check this was dependent on type registration order, which is wrong (reg. order change would lead to schema change). So now you can use such declarations only with many-to-one relationship. But I should mention everything worked fine even without this fix. Test code is here: http://goo.gl/qaWW Its output:
Alex (Xtensive) wrote:Just checked your case:
So likely, there was something different. Alex (Xtensive) wrote:Can you send us your sample? Yes, you can write "select spec.Title + m.FullName + m.Email" there, but in this case this will be executed as SQL, so you will get just this string as result, none of objects will be materialized (i.e. if you'll use them later in the same transaction, they'll need to be fetched). Dmitri Maximov (Xtensive) wrote:Hello Diego, it seems that you have a mistake in the model, I mean, values of PairTo property of Association attribute were wrong. Here is the correct snippet:
&
psulek wrote:
I found 2 errors in your sample: 1. on both classes you missing attribute [HierarchyRoot] 2. you have wrong construction of anonymous type in final select projection, you have:
But definition must be like that:
Important here is that you must specify names of properties for anonymous type like Title, FullName, Email Here is working code that i update:
psulek wrote:And which version of DO4 do you have? I have tested it on 4.3RC2 with success. I dont know how to help you more, can you post sample (zip with solution and project) which does not work for you. Or some details how are named your existing DB, and sample data information you have in existing tables, that i can reconstruct your case properly. Alex (Xtensive) wrote:Does this correct: the question isn't about how to perform the LINQ query (that's described in Manual), but how to serialize client-side query, send it to server and get back the results? If I'm wrong, please describe what you're going to perform more precisely. Unfortunately, I really don't have enough time to figure out this from posted solutions... psulek wrote:if you want to pass DO linq query from client to server, you must serialized linq query expression on client side like this:
here buffer will contains byte array of serialized expression which will be passed to server (by any channel-wcf/socket/...) and deserialize byte array to expression on server side:
Here you can also on client side serialize assembly qualified type name of type T you are quering agains Query.All<t> and put this information into buffer. On server side you can deserialize this assembly qualified type name and build runtime Type (Type.GetType(string)). Server side example:
Alex (Xtensive) wrote:We can download & task the code, but normally we do this for paid customers only. Another reason is language: most of us know English and Russian, but not Spanish. Imagine we'd ask to to study the code with Russian type and field names. So I'd recommend you to try narrow down the case. Questions like "The problem is HOW CAN I WRITE THE LINQ QUERY" look simply strange, taking into account there is a large part in manual about this. I.e. ask more precise question. E.g. I simply don't understand what is implied here, although I read everything. If someone else understands the case, I'd be happy to hear the explanation... I'm sorry for such an answer, but this is the case when it's difficult to help, because there is no precise question. Ok, it seems the simplest way is to send us the whole soultion, or to share it here. DiegoCorrea wrote: If you need other details or if you have doubts about the project let me know please. DiegoCorrea wrote: Any ideas? Issue created: http://code.google.com/p/dataobjectsdot ... ail?id=679 DiegoCorrea wrote: Hi Alex, I have done your recommendation about the PairTo, only in one of the Entities, but still appearing the same exception. There is a way to obtain the output that I want and save in a string variable? Thanks four help provided always. |