1
我怎樣才能insted的公共變種compiledQuery寫Func鍵< MYEntities,串,???>LINQ編譯的查詢,類別字段
public var compiledQuery = CompiledQuery.Compile((AddresEntities ctx, string name) =>
from x in ctx.User
where x.Name.Contains(name)
select new { x.Name, x.Phone});
當我嘗試像這樣我得到錯誤:僅參數表較少構造函數被支持
public static Func<AddresEntities, string, IQueryable<MYClass>> compiledQuery =
CompiledQuery.Compile((AddresEntities ctx, string name) =>
(from x in ctx.Users
where x.Name.Contains(name)
select new MYkontakt(x.Name, x.Phone)));
它不起作用。 – 2011-05-16 07:07:50
請給出您的錯誤 – anishMarokey 2011-05-16 07:09:01
無法初始化類型'Database.User_Services.MyUser'集合初始化程序 ,因爲如果它不是IEnumerable類型,它不會實現'System.Collections.IEnumerable' – 2011-05-16 07:46:27