我想從編譯的查詢中返回一個匿名類型,它從兩個表中選擇多個列。返回來自已編譯的查詢委託的匿名類型
我試着使用:
public static Func < DBEntities, string>
,但無法進行編譯。我試圖創建一個新的數據類型BOMWorkOrder,但無法使它工作。可能會缺少一些語法。
public static Func<DBEntities, string, IQueryable<BOMWorkOrder>> compiledWorkorderQuery =
CompiledQuery.Compile((DBEntities ctx, string bomNumber) =>
from items in ctx.BM10200
from orders in ctx.BM10300
where orders.Parent_Component_ID == -1 &&
orders.ITEMNMBR == bomNumber &&
orders.TRX_ID == items.TRX_ID
select new
{ bomWorkOrder =
items.TRXDATE,
orders.TRX_ID,
orders.ITEMNMBR,
orders.Assemble_Quantity
});
那裏的工作順序將是:
public class BOMWorkOrder
{
public DateTime TransactionDate { get; set; }
public string TransactionId { get; set; }
public string ItemNumber { get; set; }
public int AssemblyQuantity { get; set; }
}
它的工作。謝啦 :) – 14578446 2011-12-29 22:30:18