此代碼返回可變字段集的,我想返回一個強類型<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