这句话是什么意思? [英] what does mean this statement?

查看:92
本文介绍了这句话是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。在代码中看到以下代码:

  public   static   void 删除< T>(对象 primaryKey) where  T: class  
{
using (MainDataContext context = new MainDataContext())
{

MetaDataMember id = context.Mapping.GetTable( typeof (T))。RowType.IdentityMembers [ 0 ];
ParameterExpression参数= Expression.Parameter( typeof (T), );
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);

}
}



我无法理解。请指导我。

编辑:MainDataContext由Visual Studio 2010中的LinqToSql工具生成

解决方案

hello . in a code setion is see following code:

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

解决方案

这篇关于这句话是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆