EF 3.5、データベースを最初に使用します。ビューを更新した後、次のエラー メッセージを受け取りました。
エラー 1 エラー 3002: 行 866 から始まるマッピング フラグメントの問題: テーブル vPendingOrders のキー (vPendingOrders.AccountId、vPendingOrders.AccountName、vPendingOrders.ApplicationModeTypeId、vPendingOrders.CampaignWorkflowId、vPendingOrders.EndDate、vPendingOrders.HiddenInGeneralList、vPendingOrders.HiddenInOwnerList、の潜在的な実行時違反) vPendingOrders.InstanceId、vPendingOrders.OrgId、vPendingOrders.StartDate、vPendingOrders.TotalBudget): 列 (vPendingOrders.CampaignWorkflowId、vPendingOrders.InstanceId、vPendingOrders.OrgId、vPendingOrders.AccountId、vPendingOrders.AccountName、vPendingOrders.TotalBudget、vPendingOrders.StartDate、vPendingOrders.StartDate. 、vPendingOrders.HiddenInGeneralList、vPendingOrders.HiddenInOwnerList、vPendingOrders.ApplicationModeTypeId) は、EntitySet vPendingOrders のプロパティ (vPendingOrders.CampaignWorkflowId、vPendingOrders.InstanceId、vPendingOrders.OrgId、vPendingOrders.AccountId、vPendingOrders.AccountName、vPendingOrders.TotalBudget、vPendingOrders.StartDate、vPendingOrders.EndDate、vPendingOrders.HiddenInGeneralList、vPendingOrders.HiddenPendingListInOwner) にマップされます。 .ApplicationModeTypeId) を概念側で使用しますが、EntitySet の主要なプロパティ (vPendingOrders.AccountId、vPendingOrders.AccountName、vPendingOrders.ApplicationModeTypeId、vPendingOrders.CampaignWorkflowId、vPendingOrders.EndDate、vPendingOrders.HiddenInGeneralList、vPendingOrders.HiddenInOwnerList、vPendingOrders.InstanceId、vPendingOrders) を形成しません。 .OrgId、vPendingOrders.SalesRep、vPendingOrders.StartDate、vPendingOrders.総予算)。
ご覧のとおり、私の新しいフィールド FullName、Email、および ContactId はありません
ビューは次のようになります。
CREATE VIEW [dbo].[vPendingOrders]
AS
SELECT TOP (100) PERCENT wf.CampaignWorkflow.CampaignWorkflowId, wf.CampaignWorkflow.InstanceId, dbo.vCampaigns.OrgId, wf.CampaignWorkflow.CampaignId,
dbo.vCampaigns.AccountId, wf.CampaignWorkflow.HasProposalReview, wf.CampaignWorkflow.HasMediaReview, wf.CampaignWorkflow.HasTraffickingEnabled,
dbo.vCampaigns.AccountName, wf.CampaignWorkflow.HasAuthorizedCreditCard, wf.CampaignWorkflow.HasAppliedForCredit, wf.CampaignWorkflow.HasDrops,
dbo.vCampaigns.TotalBudget, wf.CampaignWorkflow.StateMessage, dbo.vCampaigns.StartDate, dbo.vCampaigns.EndDate, dbo.vCampaigns.OwnerId,
dbo.vCampaigns.OwnerType, dbo.vCampaigns.HiddenInGeneralList, dbo.vCampaigns.HiddenInOwnerList, wf.CampaignWorkflow.ApplicationModeTypeId,
dbo.vCampaigns.SalesRep, dbo.vCampaigns.AdvertiserName,
-- new values
dbo.vCampaigns.FullName, dbo.vCampaigns.Email, dbo.vCampaigns.ContactId
FROM wf.CampaignWorkflow INNER JOIN
dbo.vCampaigns ON wf.CampaignWorkflow.CampaignId = dbo.vCampaigns.CampaignId
ORDER BY wf.CampaignWorkflow.CampaignWorkflowId DESC
また、既存の列だけをエイリアス (重複) として追加しようとしました: dbo.vCampaigns.AdvertiserName 次の 24 番目の列\プロパティの結果は同じです - エラー 3002
そのフィールドのプロパティでは、EntityKey は false で、Nullable は true です。
また、ここに別のビューを追加します。そこから値を取得します。
SELECT cam.Campaign.CampaignId, cam.Campaign.OrgId, cam.Campaign.OwnerId, cam.Campaign.AccountId,
-- here they are
cam.Campaign.ContactId, SalesRep.FullName, SalesRep.Email,
cam.Campaign.AgencyId,
cam.Campaign.CampaignName, Advertiser.AccountName, Agency.AccountName AS AgencyName, cam.CampaignStatus.Code AS Type,
cam.Campaign.OwnerType, cam.Campaign.StartDate, cam.Campaign.EndDate, dbo.fnGetCampaignRunStatus(cam.Campaign.CampaignId, NULL)
AS Status, wf.CampaignWorkflow.StateMessage, wf.CampaignWorkflow.CampaignWorkflowId, cam.Campaign.TotalBudget,
cam.Campaign.HiddenInGeneralList, cam.Campaign.HiddenInOwnerList, cam.Campaign.Note,
CASE WHEN wf.CampaignWorkflow.ApplicationModeTypeId = 2 THEN CASE WHEN SalesRep.ContactId IS NULL
THEN Owner.FullName ELSE SalesRep.FullName END ELSE CASE WHEN SalesRep.ContactId IS NULL
THEN 'N/A' ELSE SalesRep.FullName END END AS SalesRep, CASE WHEN wf.CampaignWorkflow.ApplicationModeTypeId IS NULL
THEN 1 ELSE wf.CampaignWorkflow.ApplicationModeTypeId END AS ApplicationModeTypeId,
con.CustomListItem.CustomListItemName AS AdvertiserName, cam.Campaign.ClientOrderId
FROM cam.Campaign INNER JOIN
org.Account AS Advertiser ON cam.Campaign.AccountId = Advertiser.AccountId INNER JOIN
cam.CampaignStatus ON cam.Campaign.CampaignStatusId = cam.CampaignStatus.CampaignStatusId INNER JOIN
con.Contact AS Owner ON cam.Campaign.OwnerId = Owner.ContactId LEFT OUTER JOIN
con.CustomListItem ON cam.Campaign.AdvertiserId = con.CustomListItem.CustomListItemId LEFT OUTER JOIN
wf.CampaignWorkflow ON cam.Campaign.CampaignId = wf.CampaignWorkflow.CampaignId LEFT OUTER JOIN
org.Account AS Agency ON cam.Campaign.AgencyId = Agency.AccountId AND cam.Campaign.AgencyId = Agency.AccountId LEFT OUTER JOIN
con.Contact AS SalesRep ON cam.Campaign.SalesRepId = SalesRep.ContactId