var query = (from order in context.MyOrderDetails
where order.UserDomainName == userName
select new
{
order.AccountID,
order.OrderNumber,
order.OrderStatus,
order.StartDate,
order.EndDate,
order.Advertiser,
order.Campaigne,
order.BookedRevenue,
order.CreativeCount,
order.MissingCreative,
order.MissingCreative,
order.MissingCount,
order.CreativeCount,
order.NotStartedCount,
order.OrderItemActiveCount,
order.OrderItemCompletedCount,
order.OrderItemCount,
order.BookedImpressions,
order.UACount,
order.UAThroughRate,
order.UACPM,
order.UADeliveredImpressionCount,
order.UADeliveredRevenue,
order.UAImpressionGoal,
order.UACount,
order.MissingCount,
order.MissingCreative31to45Count,
order.MissingCreative46to60Count,
order.MissingCreative61to90Count,
order.OrderLifeToDateClickCount,
order.OrderDeliveredImpressionCount,
order.OrderLifeToDateDiscountedSalesUSD,
order.OrderLifeToDateScheduledImpressionCount,
order.ActiveState,
order.OrderProposalExpirationDate,
order.OrderProposalExtensionCount,
order.UAOrderedImpressionCount,
order.UAPacingLTDDeliveredImpressionCount,
order.UAPacingLTDScheduledImpressionCount,
order.UAPacingPct,
order.PremiumLateCreativeCount,
order.PremiumMissingCreative16to30Count,
order.PremiumAssignedCreativeCount,
order.PremiumMissingCreativeCount,
order.PrimaryAeName,
order.UAScheduledImpressionCount,
order.TotalDayCount,
order.UserDomainName,
order.UADeliveredImpressionPercent,
order.DraftOrderCount,
order.ProposedOrderCount,
order.ApprovedOrderCount,
order.Filter_OrderGroup,
order.Filter_LineofBusiness,
order.Filter_Status,
order.Filter_ActiveState,
order.Filter_StartdateNext30,
order.Filter_StartdateNext60,
order.Filter_StartdateNext90,
order.Filter_EndDateNext30,
order.Filter_EndDateNext60,
order.Filter_EndDateNext90,
order.LineEvent,
order.IsFavorite,
order.ClientID
}).ToList<IMyOrderDetails>() ;
It gives me the the bunch of errors
System.InvalidCastException was unhandled by user code
Message=Unable to cast object of type 'DataServiceOrderedQuery[<>f__AnonymousType2`65[System.String,System.String,System.String,System.Nullable`1[System.DateTime],System.Nullable`1[System.DateTime],System.String,System.String,System.Decimal,System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Decimal,System.Decimal,System.Nullable`1[System.Decimal],System.Nullable`1[System.Decimal],System.Nullable`1[System.Decimal],System.Decimal,System.Decimal,System.Decimal,System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Decimal,System.Decimal,System.Decimal,System.Decimal,System.String,System.Nullable`1[System.DateTime],System.Int32,System.Decimal,System.Decimal,System.Decimal,System.Nullable`1[System.Decimal],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.String,System.Decimal,System.Int64,System.String,System.Nullable`1[System.Decimal],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.Nullable`1[System.Int32],System.String,System.String,System.String,System.String,System.Nullable`1[System.Byte],System.Nullable`1[System.Byte],System.Nullable`1[System.Byte],System.Nullable`1[System.Byte],System.Nullable`1[System.Byte],System.Nullable`1[System.Byte],System.String,System.Int32,System.Nullable`1[System.Int64]]]' to type 'System.Data.Services.Client.DataServiceQuery`1[Microsoft.Advertising.SalesDashboard.Modules.OrderPerformance.Models.OrderPerformance.MyOrderDetails]'.
StackTrace:
at Microsoft.Advertising.SalesDashboard.Modules.OrderPerformance.Services.OrderRepository.<>c__DisplayClass85.<GetMyOrderDetailsDrillDown>b__83(PerformanceEntities context)
at System.Linq.Observable.<>c__DisplayClass275`2.<>c__DisplayClass277.<Select>b__274(TSource x)
InnerException:
I even tried by select new IMyOrderDetails
{
order.AccountID,
order.OrderNumber,
order.OrderStatus
but then it gives me the error can not create the instance.Could any one please let me know the possible solutions for this.