Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello . in a code setion is see following code:
C#
public static void Delete<T>(object primaryKey) where T : class
       {
           using (MainDataContext context = new MainDataContext())
           {

               MetaDataMember id = context.Mapping.GetTable(typeof(T)).RowType.IdentityMembers[0];
               ParameterExpression parameter = Expression.Parameter(typeof(T), "item");
               T entity = context.GetTable<T>().Single<T>(Expression.Lambda<Func<T, bool>>(Expression.Equal(Expression.Property(parameter, id.Member.Name), Expression.Constant(primaryKey)), parameter));
               context.GetTable<T>().DeleteOnSubmit(entity);

           }
       }

i can't understandit. please guide me.
edited : MainDataContext is generated by LinqToSql tools in visual studio 2010
Posted
Updated 30-Jul-14 1:36am
v5
Comments
OriginalGriff 30-Jul-14 7:14am    
Which bit?
aliwpf 30-Jul-14 7:42am    
i edit question.
ZurdoDev 30-Jul-14 7:25am    
What is MainDataContext?
aliwpf 30-Jul-14 7:43am    
that is generated by LinqToSql tools in VS 2010
Nathan Minier 30-Jul-14 8:35am    
It's the class built by LINQ to SQL when you mapped your data source (database). It inherits from type System.Data.Linq.DataContext

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