Click here to Skip to main content
12,452,344 members (56,736 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL LINQ C#4.0
HI guys,
I am creating an Permission Repository and this code is from my book.

public void SavePermission(Permission permission)
{
    using(FisharooDataContext dc = Connection.GetContext())
    {
      if(permission.PermissionID > 0)
      {
         <u>dc.Permissions.Attach(permission,true);</u>

I get error when i use dc.Permissions.Attach(permission,true).. it gives me an error saying it cant take more than 2 arguments.

AND

when is try using
dc.Permission.InsertOnSubmit(permission); 
and
dc.SubmitChanges();

my visual studio's intellisense cannot recognize InsertOnSubmit or SumbmitChanges

maybe i should use an using statment but i dont kno which!

and i even reffered my code to this webpage
http://code.google.com/p/eboxshowsns/source/browse/trunk/EboxShowSNS.Core/DataAccess/Impl/PermissionRepository.cs?spec=svn6&r=6[^][^]

but i dont find any differences.

Please help me out with my above 3 mentioned problems.

Thank you.
Posted 13-May-12 14:51pm
Sipherz450
Updated 13-May-12 17:44pm
v2
Comments
SASS_Shooter 14-May-12 17:21pm
   
For the InsertOnSubmit and SubmitChanges issues, did you look to see if you have
using System.Data.Linq?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

is this a typo?
dc.Permissions.InsertOnSubmit(permission);
I'm sure it is as the code above and on the linked source says so.

I assume that your (Connection)conn.GetContent returns a System.Data.Linq.DataContext instance? If this has been instanciated then why would you need to attach a record to it when the record already exists? Are you using some form of data caching? The way that changes to a specific record would be acheived is to select the record out of the table, update eacha and every property and then just dc.SubmitChanges() (I think :S)

Are you sure that the "Permissions" table has a capital P as automatically generated dbml files usually put this to lower case, as with the entity type "permission"

If I have all of this wrong then please post the proof in code as there may be a small error there you have missed.

Hope this is useful Wink | ;)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 16 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100