Issue with entity set
-
2012년 2월 13일 월요일 오후 2:08
Freinds,
My entity set for "single payment" has one record and "company payment" has zero records but still the count property for "company payment" entity shows 1. Can any one explain me why this happens.
I have a single entity "Payment" on which I have derived two new entities "Single Payment" and "Company Payment"
Any suggestions will be highly appreciated.
Thanks
모든 응답
-
2012년 2월 13일 월요일 오후 2:56
Please show the code.
.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful". -
2012년 2월 15일 수요일 오전 2:35중재자
Hi Vipul Pujari,
Welcome to MSDN Forum.
Could you please post the code here? This is, so we can help you more effectively.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 20일 월요일 오후 2:10
IndividualPayment and CompanyPayment is inherited from payment table.
Discriminator property for CompanyPayment table is "ApplicantType" with value "C" and
Discriminator property for IndividualPayment table is "ApplicantType" with value "I"
Code used to access individualpayment and companypayment
DataClasses1DataContext objDataClasses1DataContext = new DataClasses1DataContext();
LeaseTransaction objLeaseTransaction = objDataClasses1DataContext.LeaseTransactions.Where(x => x.TransactionID == "309abea6-b13a-48c8-a6ad-d12118130eb8").FirstOrDefault();Following is the output when I view IndividualPayments in watch window. Please note in database there is only one record for CompanyPayment in Payment table.
- 편집됨 Vipul Pujari 2012년 2월 21일 화요일 오전 8:18
-
2012년 2월 22일 수요일 오전 2:38중재자
Hi Vipul Pujari,
The technology you used is Linq to SQL or Entity Framework? This is Linq to SQL Forum, but from the post, I feel it is a Entity Framework project.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 22일 수요일 오전 10:39
No we have implemented this in linq to sql.
Thanks and best regards,
Vipul
-
2012년 2월 23일 목요일 오전 7:37중재자
Hi Vipul Pujari,
I create a simple demo and test on my computer, everything works well. I think it may have something wrong in the .designer.cs file, please open that file and look at the super class 'Payments', it should have some attributes like below
and above the ApplicationType, it should have a attribute like below
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 23일 목요일 오전 11:07
Thank you Allen for replying
I belive the attribute you have suggested is already present in designer.cs file. Please have a look
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Payment")]
[global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="I", Type=typeof(IndividualPayment), IsDefault=true)]
[global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="C", Type=typeof(CompanyPayment))]
public partial class Payment : INotifyPropertyChanging, INotifyPropertyChanged[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ApplicantType", DbType="Char(1)", IsDiscriminator=true)]
public char ApplicantType
{
get
{
return this._ApplicantType;
}
set
{
if ((this._ApplicantType != value))
{
this.OnApplicantTypeChanging(value);
this.SendPropertyChanging();
this._ApplicantType = value;
this.SendPropertyChanged("ApplicantType");
this.OnApplicantTypeChanged();
}
}
}The only difference between your implementation of code and my code is the datatype of "applicantType" column.
Thanks and best regards,
Vipul
- 편집됨 Vipul Pujari 2012년 2월 24일 금요일 오전 5:49
-
2012년 2월 24일 금요일 오전 7:04중재자
Hi Vipul Pujari,
If possible, could you please upload the project to SkyDrive and post the link here? You have mentioned, the only difference between my simulate demo and your project is the type of applicantType, but this difference certianly will not lead the issue. If you can upload the project, I will help you to test it and try to find the root cause.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 24일 금요일 오전 8:03
https://skydrive.live.com/redir.aspx?cid=16ea07f5df7ddce7&resid=16EA07F5DF7DDCE7!187&parid=16EA07F5DF7DDCE7!186&authkey=!AAvoyAPcU5-gGJc
The project contain sample implementation of code. Please have a look
Thanks and best regards,
Vipul
-
2012년 2월 27일 월요일 오전 8:31중재자
Hi Vipul Pujari,
Could you please upload the database with the data? I downloaded the project, build the same database in my SQL Server2008 R2, and modify the connection string as mine, every thing still works well.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 2월 28일 화요일 오후 12:55
Here is the link
https://skydrive.live.com/redir.aspx?cid=16ea07f5df7ddce7&resid=16EA07F5DF7DDCE7!188&parid=16EA07F5DF7DDCE7!186
Thanks and best regards,
Vipul
-
2012년 2월 29일 수요일 오전 9:40중재자
Hi Vipul Pujari,
I have download the project and repro the issue. I have not find the reason, I will involve my workmates to research it and come back as soon as possible.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 3월 1일 목요일 오전 8:25중재자
Hi Vipul Pujari,
I have modified the project and make it works well. First of all, if you wnat to create an inheritance relationship between 'Payment' and 'IndividualPayment', 'CompanyPayment', you needn't delete the relationship between 'Payment' and 'LeaseTransaction', jsut create the two entities to inheriting the 'Payment'. Second, both of the sub entitites have a 'LeaseTransactionID' property, it makes no sense, it should in the super entity. Below is the dbml picture.
If you want to query out the sub entity, you can write the code below
var test = objLeaseTransaction.Payments.OfType<CompanyPayment>();
After modifying, everything works well, the IndividualPayment.Count is 0 and the CompanyPayment.Count is 1.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
- 답변으로 표시됨 Vipul Pujari 2012년 3월 1일 목요일 오후 4:05
-
2012년 3월 1일 목요일 오후 4:05
Thanks it worked!!!!
Thanks and best regards,
Vipul
-
2012년 3월 2일 금요일 오전 1:39중재자
Hi Vipul Pujari,
Glad to help! If you have any problems, please feel free to post in the forum.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 3월 5일 월요일 오후 5:01
Dear Allen,
I am facing one new issue. Here I have created a derived class "PersonGuarantorPerson" from base "TransactionMemberPerson". However when I try retrieve records from "TransactionMemberPerson" base class all records type of fetched records are of type "PersonGuarantorPerson" class. Can you suggest me the reason for this issue.
Sample code
https://skydrive.live.com/redir.aspx?cid=16ea07f5df7ddce7&resid=16EA07F5DF7DDCE7!189&parid=16EA07F5DF7DDCE7!186
Thanks and best regards,
Vipul
-
2012년 3월 6일 화요일 오전 1:45중재자
Hi Vipul,
It would be better if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
2012년 3월 6일 화요일 오전 8:33
As suggested I have created a separate thread for the issue, if possible please have look on it.
http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/e205b8a0-bb44-4d87-9f0d-2fb79be373c9
Thanks and best regards,
Vipul

