此代码返回可变字段集的,我想返回一个强类型<E>
:鉴于通用<E>如何创建一个新的E并返回它?
public IList<E> Get(Expression<Func<E, object>> selectLambda == null)
{
if (selectLambda == null)
selectLambda = p => p;
var partialSet = DC.CreateQuery<E>("[" + typeof(E).Name + "]");
foreach (var record in partialSet)
{
var tempEntity = new E(); // This is the error
MapIt(record, tempContract);
result.Add(tempContract);
}
return result;
}
重复http://stackoverflow.com/questions/840261/c-generic-new-constructor-problem ...? – JeffFerguson 2010-10-28 15:24:58