Hi Sagi,
Are you referring to the default profile provider that is using SqlExpress
as the database store? If this is the case, based on my test, the saved
personal information using profile provider will be all contained in one
table aspnet_Profile and there's only one record for one user.
Here's my test steps:
1) Create following classes:
namespace myns
{
[Serializable]
public class Member
{
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
private Policies _policies;
public Policies Policies
{
get { return _policies; }
set { _policies = value; }
}
}
[Serializable]
public class Policy
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
public Policy()
{
}
public Policy(int id, string name)
{
_id = id;
_name = name;
}
}
[Serializable]
public class Policies : List<Policy>
{
}
}
2) Edit web.config to support profile:
<profile>
<properties>
<add name="Name" type="string"/>
<add name="Member" type="myns.Member"/>
</properties>
</profile>
3) In Default.aspx.cs
if (string.IsNullOrEmpty(Profile.Name))
{
Profile.Name = "Test";
}
if (Profile.Member.Policies == null)
{
Profile.Member.Age = 1;
Profile.Member.Name = "Name";
Profile.Member.Policies = new Policies();
Profile.Member.Policies.Add(new Policy(1, "n1"));
Profile.Member.Policies.Add(new Policy(2, "n2"));
}
4) Open App_Data\AspNetDb.mdf, view table aspnet_Profile's data. It only
contains one record for the user. The field PropertyNames has following
content: "Name:S:0:4:Member:S:4:365:" while there're other two fields used
to store the serialized value:
Test<?xml version="1.0" encoding="utf-16"?>
<Member xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Name</Name>
<Age>1</Age>
<Policies>
<Policy>
<Id>1</Id>
<Name>n1</Name>
</Policy>
<Policy>
<Id>2</Id>
<Name>n2</Name>
</Policy>
</Policies>
</Member>
I think you may referring to other profile provider. Please let me know
your usage scenario. Thanks.
Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Shkedy - 22 Jan 2007 23:13 GMT
Right - the default profile provider. The problem was with the serilization
of a list object that is nested inside another object.
If I Look into the serialized object the list elements are duplicated which
cause the object to be really big. I am attaching a section of the
serialized text and the list objects keep repeating:
<Member>
<policies>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>18</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>124</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>19</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-08-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
<Policy>
<MemberID>2014918</MemberID>
<PolicyID>20</PolicyID>
<EffectiveDate>2006-12-16T00:00:00</EffectiveDate>
<TerminationDate>2007-03-16T00:00:00</TerminationDate>
<ServiceID>125</ServiceID>
</Policy>
....
That's the problem
> Hi Sagi,
>
[quoted text clipped - 149 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 23 Jan 2007 02:14 GMT
Hi Sagi,
I see.
Let's take following code for example:
[Serializable]
public class Member
{
private Policies _policies = new Policies();
(I have the policies collection created by default).
Then I have following code in Page_Load():
Profile.Member.Age = 1;
Profile.Member.Name = "Name";
Profile.Member.Policies.Add(new Policy(1, "n1"));
Profile.Member.Policies.Add(new Policy(2, "n2"));
Refreshing the page several times, and you will see duplicated policy
objects in the serialized text. This is because I'm not checking if the
policies collection is initialized or not before adding new policy objects.
Note that since Profile has already saved the object for us, when we
execute the code second time, there're already policies objects there.
If in doubt, please post some of your code how you're reading/writing the
profile. Thanks.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Shkedy - 26 Jan 2007 23:00 GMT
I think it is working now but I am still not sure what was causing it.
The way I had it in my class was different. I will keeo this in mind, thanks
for your help.
Sagi
> Hi Sagi,
>
[quoted text clipped - 37 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.