我有这个选择所有城市:
ExecuteStoreCommand<MCT_DBEntities>("select * from cities", ConnectionResolver.DB_Connection);
现在我正在尝试将其转换为Lambda,但如何将其告诉SELECT *
?
GetWithExpression<city, MCT_DBEntities>(u => u.SelectMany, ConnectionResolver.DB_Connection);
编辑:
private static TValue RetryGetWithExpression<U,T, TValue>(Func<ObjectSet<T>, TValue> func, String connection, Int32 retryInfiniteLoopGuard = 0)
where T : class
where U : ObjectContext
{
Microsoft.Practices.TransientFaultHandling.RetryPolicy policy = RetryPolicyProvider.GetSqlAzureRetryPolicy();
using (U entitiesContext = (U)Activator.CreateInstance(typeof(U), new[] { connection }))
{...}
答案 0 :(得分:1)
如果你的第一个参数是Expression<Func<T, bool>>
,你可能需要:
RetryGetWithExpression<city, MCT_DBEntities>(_ => true, ConnectionResolver.DB_Connection);
修改强> 这应该有效:
RetryGetWithExpression<MCT_DBEntities, city, IQueryable<city>>(x => x.Select(y => y),
ConnectionResolver.DB_Connection);
答案 1 :(得分:0)
你试过吗
GetWithExpression<city, MCT_DBEntities>(u => u.Select(), ConnectionResolver.DB_Connection);