Click here to Skip to main content
15,883,809 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
HI guys,
I am creating an Permission Repository and this code is from my book.

C#
public void SavePermission(Permission permission)
{
    using(FisharooDataContext dc = Connection.GetContext())
    {
      if(permission.PermissionID > 0)
      {
         <u>dc.Permissions.Attach(permission,true);</u>
      }
      else
      {
        <u> dc.Permissions.InsertOnSubmit(permision);</u>
      }<u>
      dc.SubmitChanges();</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
C#
dc.Permission.InsertOnSubmit(permission); 

and
C#
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
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

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 ;)
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900