c# - WCF SQL insert GUID conversion error -


i unsure how go this,

i want add unique identifiers users using wcf , when go add guid clients datacontext throws error

error 2
argument 1: cannot convert 'system.guid' 'servicefairy.client' c:\users\john\documents\visual studio 2010\projects\premleague\servicefairy\service1.svc.cs

any chance can help?

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.servicemodel.web; using system.text; using system.data.sqlclient; using system.diagnostics;  namespace servicefairy { // note: can use "rename" command on "refactor" menu change class     name "service1" in code, svc , config file together. public class service1 : iservice1 {     public list<match> getallmatches()     {         matchtabledatacontext context = new matchtabledatacontext();         var matches = m in context.matches orderby m.date select m;         return matches.take(100).tolist();     }      public list<premtable> gettable()     {         premcontext context = new premcontext();         var table = user in context.premtables orderby user.id select   user;         return table.take(100).tolist();     }      public dictionary<guid, uri> _clienturis = new dictionary<guid, uri>();      public void subscribe(guid clientid, string uri)     {         clientsdbdatacontext context = new clientsdbdatacontext();         context.clients.insert(clientid);                }        

the problem in subscribe method @ line:

context.clients.insert(clientid);   // error: clientid wrong type 

you're passing clientid of type guid insert() when instead should passing object of type servicefairy.client.

it looks should creating new client object , saving that:

var client = new servicefairy.client() { clientid = clientid };  // todo: set other properties context.clients.insert(client); 

as todo indicates, should setting other client properties too.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -