New Posts New Posts RSS Feed: Serialization
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Serialization

 Post Reply Post Reply
Author
antonio_sergio View Drop Down
Newbie
Newbie


Joined: 21-Oct-2010
Location: Braga
Posts: 9
Post Options Post Options   Quote antonio_sergio Quote  Post ReplyReply Direct Link To This Post Topic: Serialization
    Posted: 11-Nov-2010 at 3:51am
Good morning,
I created a query that takes as parameter an array of strings.
When I try to run my application gives me the error below:
 
There was an error while trying to serialize parameter http://ideablade.com/EntityModel:entityQuerySurrogate. The InnerException message was 'Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.
 
 
 
When I put the attribute [KnowType(typeof(string[]))] in my class it gives me another error:
 
Type 'System.Collections.Generic.List`1[System.String]' cannot be added to list of known types since another type 'System.String[]' with the same data contract name 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfstring' is already present.
 
What am I doing wrong??
 
Regards,
Sérgio Magalhães
 
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 735
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 12-Nov-2010 at 3:34pm
Hi Sergio,
 
Can you show me the snippet that is causing the issue?
 
Silvio.
Back to Top
antonio_sergio View Drop Down
Newbie
Newbie


Joined: 21-Oct-2010
Location: Braga
Posts: 9
Post Options Post Options   Quote antonio_sergio Quote  Post ReplyReply Direct Link To This Post Posted: 15-Nov-2010 at 2:42am
Hi Silvio,
 
The query on server side:
	[Query]
        public IEnumerable<WebMarca> WebFind(string[] Codigo)
        {
            List<WebMarca> lista = new List<WebMarca>();
            lista.Add(ConvertToWeb(ClsPlural.Find(Codigo)));
            return lista;
        }
The query call on client side:
	void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            EntityQuery<WebMarca> query = mgr.Find();
            string[] Codigos = new string[] { "1""aa" };
            query.AddParameter(Codigos);
            mgr.ExecuteQueryAsync<WebMarca>(query, ExecCompleted, true);
        }
 
And the error:
 
Regards,
Sérgio Magalhães
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 735
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 16-Nov-2010 at 5:08pm
Hi Sergio,
 
I could verify the behavior here.
 
Instead of using an array, you can use List<string>:
 
var Codigos = new List<string>(new string[] { "1", "aa" });
 
Regards,
   Silvio.


Edited by sbelini - 16-Nov-2010 at 5:10pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down