1

我有这个选择所有城市:

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 }))
        {...}
4

2 回答 2

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);
于 2012-12-02T16:28:44.113 回答
0

你有没有尝试过

GetWithExpression<city, MCT_DBEntities>(u => u.Select(), ConnectionResolver.DB_Connection);
于 2012-12-02T16:27:52.033 回答