Welcome to Sign in | Join | Help
in Search

read / write data cu LINQ

Last post 12-12-2008, 10:36 by Byty. 3 replies.
Sort Posts: Previous Next
  •  12-11-2008, 7:01 6395

    read / write data cu LINQ

    Deci..
    Am tras un table Server_list in design.
    Am codul de a intreoga :
    DataClassesDataContext dc = new DataClassesDataContext();
    var interogare = from ceva in dc.Server_lists
             where ceva.Server == "a"
            
    select new { ceva.Server };

    Totul merge bine...
    Si cod de a adauga:
    DataClassesDataContext dc = new DataClassesDataContext();
    Server_list server = new Server_list { Server = "adsda", Comment = "asdasd" };
    dc.Server_lists.InsertOnSubmit(server);
    dc.SubmitChanges();

    Acesta da eroare ca nu am primary key... Dupa ce definesc primary key in Design ( Primary Key la variabila ID pus pe True)  imi da eroarea : "Incorrect AutoSync specification for member 'ID' "

    Ceva idei?


    01000010010110010100001001011001
    Byty Web Site
  •  12-11-2008, 7:28 6396 in reply to 6395

    Re: read / write data cu LINQ

    Rezolvare Stick out tongue .. tot in design la acelasi camp setezi Auto-Sync:OnInsert si gata.. merge
    01000010010110010100001001011001
    Byty Web Site
  •  12-11-2008, 7:59 6397 in reply to 6396

    Re: read / write data cu LINQ

    daca tabela aveea Pk pe ea in momentul cand o adaugi in designer ar trebui sa fie ok..

    Am avut si eu surprize destule cu linq2sql


    Secolul XXI ori va fi religios ori nu va fi deloc
  •  12-12-2008, 10:36 6401 in reply to 6397

    Re: read / write data cu LINQ

    Avea PK.. si degaba.. am creat tabela tot in Visual Studio si am pus Is Ientity pe Yes..  si degaba ;) sau.. dupa am pus... nu mai stiu in orice caz.. trebuie sa fie.. setate si merge..
    01000010010110010100001001011001
    Byty Web Site
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems