GetAll() doesn't get all the items

Nov 20, 2010 at 8:50 PM

First of all, Rapid Repository is pretty straightforward to use. 

I am using Rapid Repository for a WP7 app.  I have a page (NEW) which provides the UI to create new entity.  Another page (ALL) displays all entities by calling GetAll() method on the entity repository.

I have noticed that when I enter a new entity and the page is navigated to ALL page, GetAll() method doesn't return all the entities.  If I re-start the app and go directly to ALL page, all the entities are displayed.  Is there some caching being performed?

Pratik

Nov 20, 2010 at 9:07 PM

Never mind.  Just saw your blog in which I saw how I can exclude the entity from cache and its working.

I do have a suggestion:

It may be good to implement a RemoveAll() method on the EntityCache.  That way, in a situation like above, if the entity collection is cached but a new entity is added, we can call RemoveAll() on EntityCache passing in the entity type (invalidating the cache in turn) and then GetAll() will retrieve all the records again and cache them.  For all subsequent calls where all entities are retrieved, cache will be used.

Pratik

Coordinator
Nov 20, 2010 at 9:22 PM
Hi Pratik,
 
It does sound like a possible bug with the Cache as this shouldn’t happen, I’ll take a look over this weekend to see if I can re-produce, if so I’ll release a patched version asap as ideally it would be much better for performance if the GetAll() was using memory rather than accessing the file system.
 
Thanks for the suggestion, I’ll add some remove cache methods onto the next release, possibly RemoveAll and RemoveAllByType.
 
I’ll let you know if there is a patch release.
 
Thanks
 
Sean.
Coordinator
Nov 20, 2010 at 10:05 PM
Edited Nov 20, 2010 at 10:08 PM

Hi Pratik,

I'm just taking a look through the code to try and work out how this could happen.

If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

 

For example:

  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)
  • also, are you definitely calling RapidContext.Current.SaveChanges before the GetAll is called?

Thanks Pratik, I promise to get this resolved asap.

Thanks Sean.

Nov 20, 2010 at 11:29 PM
I posted a follow up with a suggestion. I read your blog which showed about caching

Sent from my Windows Mobile phone


From: SeanMcAlinden <notifications@codeplex.com>
Sent: Saturday, November 20, 2010 5:05 PM
To: Pratik D. Kothari <pkothari@titletracking.com>
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I'm just taking a look through the code to try and work out how this could happen.

If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

For example:

  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)

Thanks Pratik, I promise to get this resolved asap.

Thanks Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Nov 21, 2010 at 11:30 PM

Sean,

I will get you some more details regarding this tomorrow morning. I am running into another issue.

GetById() – it throws an exception if you try to retrieve an entity that doesn’t exist. Should it not return null or something?

I have a scenario where I need to check whether the entity with the GUID exists or not and then if it doesn’t exist, perform an INSERT.

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Saturday, November 20, 2010 5:06 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I'm just taking a look through the code to try and work out how this could happen.

If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

For example:

  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)

Thanks Pratik, I promise to get this resolved asap.

Thanks Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 22, 2010 at 8:06 AM
Hi Pratik,

Do you think it would be better for it to return Null or should I add some methods like MyRepository.Exists(Id) - so you could do something like: if(customerRepository.Exists(customerId)) { return customerRepository.GetById(customerId) } - this would probably perform a little better as I wouldn't have to catch and exception and then return null, I could literally just do a quick search through the file collection for the file name.

What do you think?

Cheers,

Sean


From: [email removed]
To: [email removed]
Date: Sun, 21 Nov 2010 15:30:10 -0800
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: pratikkothari1
Sean,

I will get you some more details regarding this tomorrow morning. I am running into another issue.
GetById() – it throws an exception if you try to retrieve an entity that doesn’t exist. Should it not return null or something?

I have a scenario where I need to check whether the entity with the GUID exists or not and then if it doesn’t exist, perform an INSERT.

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Saturday, November 20, 2010 5:06 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]


From: SeanMcAlinden
Hi Pratik,
I'm just taking a look through the code to try and work out how this could happen.
If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

For example:
  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)
Thanks Pratik, I promise to get this resolved asap.
Thanks Sean.
Read the full discussion online.
To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)
To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Read the full discussion online.
To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)
To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
Nov 22, 2010 at 1:21 PM

Sean,

I like your idea. Can you please send me the implementation for that method so I can start using it in my project?

Also, DeleteAll() may be good to have on the Repository class as well in addition to the Cache stuff we discussed earlier.

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Monday, November 22, 2010 3:07 AM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

Do you think it would be better for it to return Null or should I add some methods like MyRepository.Exists(Id) - so you could do something like: if(customerRepository.Exists(customerId)) { return customerRepository.GetById(customerId) } - this would probably perform a little better as I wouldn't have to catch and exception and then return null, I could literally just do a quick search through the file collection for the file name.

What do you think?

Cheers,

Sean


From: [email removed]
To: [email removed]
Date: Sun, 21 Nov 2010 15:30:10 -0800
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: pratikkothari1

Sean,

I will get you some more details regarding this tomorrow morning. I am running into another issue.
GetById() – it throws an exception if you try to retrieve an entity that doesn’t exist. Should it not return null or something?

I have a scenario where I need to check whether the entity with the GUID exists or not and then if it doesn’t exist, perform an INSERT.

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Saturday, November 20, 2010 5:06 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]


From: SeanMcAlinden

Hi Pratik,
I'm just taking a look through the code to try and work out how this could happen.
If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

For example:

  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)

Thanks Pratik, I promise to get this resolved asap.
Thanks Sean.

Read the full discussion online.
To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)
To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Read the full discussion online.
To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)
To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Nov 22, 2010 at 6:28 PM

Sean,

1) I am not doing EageLoad…

2) There are two different entity types that are being loaded. Very simple entities (one has string, datetime properties and the other has string property in addition to the Id property)

3) Initially, I had caching, so I believe when the new entity was added and I navigated back to the page that calls GetAll(), the new record was not shown. But when I removed caching for that entity, everything works correctly. That is where I suggested that it would be good to have a method on the cache to invalidate the cache for an entity. So, a user can keep caching enabled and only invalidate the cache when necessary.

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Saturday, November 20, 2010 5:06 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I'm just taking a look through the code to try and work out how this could happen.

If you don't mind, could you give me an overview of the situation that is causing the bug so I can run a similar test.

For example:

  • Are you calling EntityCache.EagerLoad<YourType>() at the start of the app or at any other point within the app?
    If so, roughly how many entities are being loaded. (Just in case there is possibility of a threading issue I can look into)
  • Also could you give me an idea of what is on your entity so I can test with something of a similar size/complexity.
  • I'm assuming there is definitely no caching within your app that could cause this, are you literally saving an entity, then navigating to a page that calls GetAll() and the result from the GetAll() is missing the new entity (i.e it is definitely not the silverlight page that is somehow caching the rendered view.)

Thanks Pratik, I promise to get this resolved asap.

Thanks Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 23, 2010 at 8:34 AM

Hi Pratik,

I'll hopefully get an implementation into source control this week at some point, I'll let you know when it is done.

With the caching, it sounds like a bug I'm going to try and reproduce because in your situation, you should be able to keep caching on.

 

Basically what should happen looks like the following:

  • New entity added to repository
  • RapidContext.Current.Savechanges()
  • The Context saves the file and also adds the new entity into the current cache
  • GetAll() retrieves all entities from the cache including the new one added (You shouldn't need to invalidate the cache or restart)

I'm currently sorting out my tests and will thoroughly test around this area to see why this isn't working for you.

Kind Regards,

Sean

Coordinator
Nov 23, 2010 at 9:13 PM

Hi Pratik,

I've added an Exists method to the repository as promised.

If you download the latest code you'll find it in there.

Kind Regards,

Sean.

 

Nov 23, 2010 at 9:27 PM

Sean,

Thanks a bunch. I will try it out tonight.

Your project has helped me out a lot. It is pretty simple to use and you have provided awesome response.

Quick question – If an entity contains a byte[], say a photo that was taken by the user, can that be stored as well along with the entity?

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Tuesday, November 23, 2010 4:14 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I've added an Exists method to the repository as promised.

If you download the latest code you'll find it in there.

Kind Regards,

Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 23, 2010 at 9:42 PM

Hi Pratik,

I'm really glad you like it, I really enjoy building things like this, gives me a nice break from my normal work (banking apps).

Our discussions have given me some great ideas so thanks to you as well.

You can definitely have a byte array property on your entity, it will save and retrieve fine.

Thanks

Sean.

PS. if you have a blog, I would be really grateful for any links to here or my blog.

Nov 24, 2010 at 8:44 AM

Sean,

Just wanted to let you know couple of things:

1) Exists() check works great

2) I made a small change to this method in RapidContext.cs (In my scenario I want to persist an entity with a GUID value that I have defined as a constant). This way, several pages can use this entity using the pre-defined GUID to share some information. Let me know your thoughts if you see a better solution.

public void SaveChanges()
{
foreach (OperationRequest request in this.operationRequests)
{
switch (request.OperationRequestType)
{
case OperationRequestType.Add:
// Pratik
if ((((IRapidEntity)request.Entity).Id == Guid.Empty) || (((IRapidEntity)request.Entity).Id == null))
((IRapidEntity)request.Entity).Id = Guid.NewGuid();

var addString = this.serialiser.Serialise(request.EntityType, request.Entity);
this.fileManager.Save(request.EntityType, ((IRapidEntity)request.Entity).Id, addString);
AddToCache(request.EntityType, (IRapidEntity)request.Entity);
break;
case OperationRequestType.Update:
var updateString = this.serialiser.Serialise(request.EntityType, request.Entity);
this.fileManager.Save(request.EntityType, request.EntityId, updateString);
EntityCache.Update(request.EntityType, request.EntityId, request.Entity);
break;
case OperationRequestType.Delete:
this.fileManager.Delete(request.EntityType, request.EntityId);
EntityCache.Remove(request.EntityType, request.EntityId);
break;
}
}

DeleteAllOperationRequests();
}

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Tuesday, November 23, 2010 3:34 AM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I'll hopefully get an implementation into source control this week at some point, I'll let you know when it is done.

With the caching, it sounds like a bug I'm going to try and reproduce because in your situation, you should be able to keep caching on.

Basically what should happen looks like the following:

  • New entity added to repository
  • RapidContext.Current.Savechanges()
  • The Context saves the file and also adds the new entity into the current cache
  • GetAll() retrieves all entities from the cache including the new one added (You shouldn't need to invalidate the cache or restart)

I'm currently sorting out my tests and will thoroughly test around this area to see why this isn't working for you.

Kind Regards,

Sean

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 24, 2010 at 1:27 PM

Hi Pratik,

I would probably  have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.

Something like:

public static class MySharedEntity
{
    public static MyEntity Entity { get; set; }
}

public class MyClass
{
    MyEntity newEntity = new MyEntity();

// add values etc. MySharedEntity.Entity = newEntity; MyRepository.Add(newEntity); RapidContext.CurrentContext.SaveChanges(); } public class MyOtherClass { var sharedEntity = MySharedEntity.Entity; // id is populated by reference so you can update/delete etc. MyRepository.Update(sharedEntity);
RapidContext.CurrentContext.SaveChanges(); }

Hope this makes sense.

 

Sean.

Nov 27, 2010 at 9:14 PM

Sean,

Let me pick your brain a little J

I have had pretty good success in using your library for performing CRUD operations in my WP7 app.

Here is the scenario where I can use some guidance:

I have an entity say –

Customer which implements IRapidEntity and has a corresponding repository.

Customer class contains an instance of another class called Photo (similary to how you have an Address instance in your examples in the download)

Photo.cs is attached with this email.

Now, in my wp7 app, I have a page where a customer record is retrieved. This page also contains a checkbox which is checked or unchecked based on if a photo is attached with this customer.

So, initially for a new customer entity, the checkbox is unchecked and if you take a photo and set the instance of Photo, then the checkbox is checked.

There is another button which when clicked will show the photograph to the user.

Everything is working correctly but all the photo content as the byte[] is read everytime a customer is displayed even though all I need to do then is to check/uncheck the checkbox. To make it worse, when I display several customers in a list, each customer’s photo instance is retrieved as well. Only if the user clicks the button, I want to retrieve the photo content as bytes and display that to the user. So, basically, I am trying to achieve lazy loading so the picture content is only loaded when the actual picture needs to be displayed to the user so the speed of the pages can be optimized.

Thanks in advance,

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Wednesday, November 24, 2010 8:28 AM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,

I would probably have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.

Something like:

public static class MySharedEntity
{
    public static MyEntity Entity { get; set; }
}
 
public class MyClass
{
    MyEntity newEntity = new MyEntity();

// add values etc.
    MySharedEntity.Entity = newEntity;
 
    MyRepository.Add(newEntity);
 
    RapidContext.CurrentContext.SaveChanges();
}
 
public class MyOtherClass
{
    var sharedEntity = MySharedEntity.Entity;
    
   // id is populated by reference so you can update/delete etc.
    MyRepository.Update(sharedEntity);

RapidContext.CurrentContext.SaveChanges();
}

Hope this makes sense.

Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 28, 2010 at 9:23 AM
Hi Pratik,
In the next couple of days I'm going to be checking in a view feature which will solve the issue, basically you will be able to create a limited view which will be much faster to load, providing you store the id on the view, you can then load the full entity when required by calling getbyid.
I'll let you know when it's in.
This will be the main feature of V2 which will be released fully over the next week or two.
Kind regards, Sean

Sent from my Windows Phone

From: pratikkothari1
Sent: 27 November 2010 21:14
To: sean.f.mcalinden@live.co.uk
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]



> From: pratikkothari1
>
> Sean,Let me pick your brain a little JI have had pretty good success in using your library for performing CRUD operations in my WP7 app.Here is the scenario where I can use some guidance:I have an entity say – Customer which implements IRapidEntity and has a corresponding repository.Customer class contains an instance of another class called Photo (similary to how you have an Address instance in your examples in the download)Photo.cs is attached with this email.Now, in my wp7 app, I have a page where a customer record is retrieved. This page also contains a checkbox which is checked or unchecked based on if a photo is attached with this customer.So, initially for a new customer entity, the checkbox is unchecked and if you take a photo and set the instance of Photo, then the checkbox is checked.There is another button which when clicked will show the photograph to the user.Everything is working correctly but all the photo content as the byte[] is read everytime a customer is displayed even though all I need to do then is to check/uncheck the checkbox. To make it worse, when I display several customers in a list, each customer’s photo instance is retrieved as well. Only if the user clicks the button, I want to retrieve the photo content as bytes and display that to the user. So, basically, I am trying to achieve lazy loading so the picture content is only loaded when the actual picture needs to be displayed to the user so the speed of the pages can be optimized.Thanks in advance,PratikFrom: SeanMcAlinden [mailto:notifications@codeplex.com]
> Sent: Wednesday, November 24, 2010 8:28 AM
> To: Pratik D. Kothari
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,I would probably have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.Something like:public static class MySharedEntity{ public static MyEntity Entity { get; set; }} public class MyClass{ MyEntity newEntity = new MyEntity();
> // add values etc. MySharedEntity.Entity = newEntity; MyRepository.Add(newEntity); RapidContext.CurrentContext.SaveChanges();} public class MyOtherClass{ var sharedEntity = MySharedEntity.Entity; // id is populated by reference so you can update/delete etc. MyRepository.Update(sharedEntity);
> RapidContext.CurrentContext.SaveChanges();}Hope this makes sense.Sean.Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>
>
Nov 29, 2010 at 4:03 AM

Sean,

Sounds promising. Looking forward to it.

I noticed the signature in your email J Are you using a WP7 device?

Pratik

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Sunday, November 28, 2010 4:23 AM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

From: SeanMcAlinden

Hi Pratik,
In the next couple of days I'm going to be checking in a view feature which will solve the issue, basically you will be able to create a limited view which will be much faster to load, providing you store the id on the view, you can then load the full entity when required by calling getbyid.
I'll let you know when it's in.
This will be the main feature of V2 which will be released fully over the next week or two.
Kind regards, Sean

Sent from my Windows Phone


From: pratikkothari1
Sent: 27 November 2010 21:14
To: sean.f.mcalinden@live.co.uk
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]



> From: pratikkothari1
>
> Sean,Let me pick your brain a little JI have had pretty good success in using your library for performing CRUD operations in my WP7 app.Here is the scenario where I can use some guidance:I have an entity say – Customer which implements IRapidEntity and has a corresponding repository.Customer class contains an instance of another class called Photo (similary to how you have an Address instance in your examples in the download)Photo.cs is attached with this email.Now, in my wp7 app, I have a page where a customer record is retrieved. This page also contains a checkbox which is checked or unchecked based on if a photo is attached with this customer.So, initially for a new customer entity, the checkbox is unchecked and if you take a photo and set the instance of Photo, then the checkbox is checked.There is another button which when clicked will show the photograph to the user.Everything is working correctly but all the photo content as the byte[] is read everytime a customer is displayed even though all I need to do then is to check/uncheck the checkbox. To make it worse, when I display several customers in a list, each customer’s photo instance is retrieved as well. Only if the user clicks the button, I want to retrieve the photo content as bytes and display that to the user. So, basically, I am trying to achieve lazy loading so the picture content is only loaded when the actual picture needs to be displayed to the user so the speed of the pages can be optimized.Thanks in advance,PratikFrom: SeanMcAlinden [mailto:notifications@codeplex.com]
> Sent: Wednesday, November 24, 2010 8:28 AM
> To: Pratik D. Kothari
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,I would probably have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.Something like:public static class MySharedEntity{ public static MyEntity Entity { get; set; }} public class MyClass{ MyEntity newEntity = new MyEntity();
> // add values etc. MySharedEntity.Entity = newEntity; MyRepository.Add(newEntity); RapidContext.CurrentContext.SaveChanges();} public class MyOtherClass{ var sharedEntity = MySharedEntity.Entity; // id is populated by reference so you can update/delete etc. MyRepository.Update(sharedEntity);
> RapidContext.CurrentContext.SaveChanges();}Hope this makes sense.Sean.Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>
>

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Coordinator
Nov 29, 2010 at 7:08 AM
Hi Pratik,
The feature should be really useful, just tricky to get right, nearly there though.
I'm using a HTC Mozart, I'm pretty happy with, I definitely think Microsoft have made a really good start in the new os.
Sean.

Sent from my Windows Phone

From: pratikkothari1
Sent: 29 November 2010 04:03
To: sean.f.mcalinden@live.co.uk
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]



> From: pratikkothari1
>
> Sean,Sounds promising. Looking forward to it.I noticed the signature in your emailJ Are you using a WP7 device?PratikFrom: SeanMcAlinden [mailto:notifications@codeplex.com]
> Sent: Sunday, November 28, 2010 4:23 AM
> To: Pratik D. Kothari
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,
> In the next couple of days I'm going to be checking in a view feature which will solve the issue, basically you will be able to create a limited view which will be much faster to load, providing you store the id on the view, you can then load the full entity when required by calling getbyid.
> I'll let you know when it's in.
> This will be the main feature of V2 which will be released fully over the next week or two.
> Kind regards, Sean
>
> Sent from my Windows PhoneFrom: pratikkothari1
> Sent: 27 November 2010 21:14
> To: [email removed]
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]
>
>
>
>> From: pratikkothari1
>>
>> Sean,Let me pick your brain a little JI have had pretty good success in using your library for performing CRUD operations in my WP7 app.Here is the scenario where I can use some guidance:I have an entity say – Customer which implements IRapidEntity and has a corresponding repository.Customer class contains an instance of another class called Photo (similary to how you have an Address instance in your examples in the download)Photo.cs is attached with this email.Now, in my wp7 app, I have a page where a customer record is retrieved. This page also contains a checkbox which is checked or unchecked based on if a photo is attached with this customer.So, initially for a new customer entity, the checkbox is unchecked and if you take a photo and set the instance of Photo, then the checkbox is checked.There is another button which when clicked will show the photograph to the user.Everything is working correctly but all the photo content as the byte[] is read everytime a customer is displayed even though all I need to do then is to check/uncheck the checkbox. To make it worse, when I display several customers in a list, each customer’s photo instance is retrieved as well. Only if the user clicks the button, I want to retrieve the photo content as bytes and display that to the user. So, basically, I am trying to achieve lazy loading so the picture content is only loaded when the actual picture needs to be displayed to the user so the speed of the pages can be optimized.Thanks in advance,PratikFrom: SeanMcAlinden[mailto:notifications@codeplex.com]
>> Sent: Wednesday, November 24, 2010 8:28 AM
>> To: Pratik D. Kothari
>> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,I would probably have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.Something like:public static class MySharedEntity{ public static MyEntity Entity { get; set; }} public class MyClass{ MyEntity newEntity = new MyEntity();
>> // add values etc. MySharedEntity.Entity = newEntity; MyRepository.Add(newEntity); RapidContext.CurrentContext.SaveChanges();} public class MyOtherClass{ var sharedEntity = MySharedEntity.Entity; // id is populated by reference so you can update/delete etc. MyRepository.Update(sharedEntity);
>> RapidContext.CurrentContext.SaveChanges();}Hope this makes sense.Sean.Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>>
>> Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>
>
Dec 1, 2010 at 4:38 PM
Edited Dec 1, 2010 at 4:42 PM

Sean, just got myself a Samsung Focus yesterday night to test out the application I have been developing.

It looks pretty good

 

Looking forward to your changes to RapidRepository. 

 

Pratik

Coordinator
Dec 1, 2010 at 5:39 PM
Hi, the Samsung sounds really good. The new feature isn't far off, just a few bugs to sort out, I'm hoping to get some time on it tonight so I should have a better idea on how long it should take.
I'll let you know how I get on.
Regards,
Sean

Sent from my Windows Phone

From: pratikkothari1
Sent: 01 December 2010 16:39
To: sean.f.mcalinden@live.co.uk
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]



> From: pratikkothari1
>
> Sean, just got myself a Samsung Focus yesterday night to test out the application I have been developing.It looks pretty good Looking forward to your changes to RapidRepository as one of the pages in my app that displays all the data is loading rather slow ;)PratikFrom: SeanMcAlinden [mailto:notifications@codeplex.com]
> Sent: Monday, November 29, 2010 2:09 AM
> To: Pratik D. Kothari
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,
> The feature should be really useful, just tricky to get right, nearly there though.
> I'm using a HTC Mozart, I'm pretty happy with, I definitely think Microsoft have made a really good start in the new os.
> Sean.
>
> Sent from my Windows PhoneFrom: pratikkothari1
> Sent: 29 November 2010 04:03
> To: [email removed]
> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]
>
>
>
>> From: pratikkothari1
>>
>> Sean,Sounds promising. Looking forward to it.I noticed the signature in your emailJ Are you using a WP7 device?PratikFrom: SeanMcAlinden[mailto:notifications@codeplex.com]
>> Sent: Sunday, November 28, 2010 4:23 AM
>> To: Pratik D. Kothari
>> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,
>> In the next couple of days I'm going to be checking in a view feature which will solve the issue, basically you will be able to create a limited view which will be much faster to load, providing you store the id on the view, you can then load the full entity when required by calling getbyid.
>> I'll let you know when it's in.
>> This will be the main feature of V2 which will be released fully over the next week or two.
>> Kind regards, Sean
>>
>> Sent from my Windows PhoneFrom: pratikkothari1
>> Sent: 27 November 2010 21:14
>> To: [email removed]
>> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]
>>
>>
>>
>>> From: pratikkothari1
>>>
>>> Sean,Let me pick your brain a little JI have had pretty good success in using your library for performing CRUD operations in my WP7 app.Here is the scenario where I can use some guidance:I have an entity say – Customer which implements IRapidEntity and has a corresponding repository.Customer class contains an instance of another class called Photo (similary to how you have an Address instance in your examples in the download)Photo.cs is attached with this email.Now, in my wp7 app, I have a page where a customer record is retrieved. This page also contains a checkbox which is checked or unchecked based on if a photo is attached with this customer.So, initially for a new customer entity, the checkbox is unchecked and if you take a photo and set the instance of Photo, then the checkbox is checked.There is another button which when clicked will show the photograph to the user.Everything is working correctly but all the photo content as the byte[] is read everytime a customer is displayed even though all I need to do then is to check/uncheck the checkbox. To make it worse, when I display several customers in a list, each customer’s photo instance is retrieved as well. Only if the user clicks the button, I want to retrieve the photo content as bytes and display that to the user. So, basically, I am trying to achieve lazy loading so the picture content is only loaded when the actual picture needs to be displayed to the user so the speed of the pages can be optimized.Thanks in advance,PratikFrom: SeanMcAlinden[mailto:notifications@codeplex.com]
>>> Sent: Wednesday, November 24, 2010 8:28 AM
>>> To: Pratik D. Kothari
>>> Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]From: SeanMcAlindenHi Pratik,I would probably have a static variable storing the entity, then the entity can be accessed from anywhere in the app. When save changes is called on the entity, as it is still referenced, the Id will be populated so you can do normal operations on the entity.Something like:public static class MySharedEntity{ public static MyEntity Entity { get; set; }} public class MyClass{ MyEntity newEntity = new MyEntity();
>>> // add values etc. MySharedEntity.Entity = newEntity; MyRepository.Add(newEntity); RapidContext.CurrentContext.SaveChanges();} public class MyOtherClass{ var sharedEntity = MySharedEntity.Entity; // id is populated by reference so you can update/delete etc. MyRepository.Update(sharedEntity);
>>> RapidContext.CurrentContext.SaveChanges();}Hope this makes sense.Sean.Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>>>
>>> Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>>
>> Read the full discussion online.To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)To start a new discussion for this project, emailRapidRepository@discussions.codeplex.com@discussions.codeplex.comYou are receiving this email because you subscribed to this discussion on CodePlex. You canunsubscribe on CodePlex.com.Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
>
>
Coordinator
Dec 2, 2010 at 12:19 AM

Hi Pratik,

Ive started a new discussion thread for discussing the views - http://rapidrepository.codeplex.com/Thread/View.aspx?ThreadId=236790

Let me know how you get on.

Kind Regards,

Sean.

Dec 3, 2010 at 2:32 PM
Edited Dec 3, 2010 at 2:55 PM

I haven’t gotten to this yet. I am stuck on a different issue involving storage of the photo from a camera

 

Please try the following on an actual device and not the emulator as the emulate camera images are too small in size. Also, you will have to disconnect Zune as there are some issues. You can use the WPConnect tool as mentioned here while debugging from the device. http://blogs.msdn.com/b/katriend/archive/2010/10/26/quick-tip-using-the-wp-connect-utility-instead-of-zune-client-windows-phone-7.aspx

 

While trying to save a record with a photo taken from the camera (photo size around 1.2 Mb), the code runs extremely slow (take around 8-10 seconds or more sometimes and app gets killed by the OS)

Please see the attached sample code and if you can help me figure out the issue, that will be great.

 

I have modified your TestMobileApplication sample to generate the same issue. Here are the modifications:

 

Added a Photo.cs to the Entities folder and an instance is contained inside the Customer class as a property.

AddCustomer.xaml – added two new buttons Camera, Gallery at the bottom that implement CameraCaptureTask and PhotoChooserTask respectively.

 

The following event handler inside AddCustomer.xaml.cs stores the chosen photo in the Photo property of Customer and during save, this data is written to the IsolatedStorage using RapidRepository (it seems that during Serialize() method of the Serializer class, it is taking a long time – during writing and retrieval)

 

 

/// <summary>
/// Event handler for the CameraCapture or the PhotoChooser task. This event handler sets the properties
///for the Photo instance of this entry.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PhotoProviderTaskCompleted(object sender, PhotoResult e)
{
// Load the photo from the task result
if (e != null && e.TaskResult == TaskResult.OK)
{
var imageBits = new byte[(int)e.ChosenPhoto.Length];
e.ChosenPhoto.Read(imageBits, 0, imageBits.Length);
e.ChosenPhoto.Seek(0, System.IO.SeekOrigin.Begin);

var name = String.Format("MS_{0:yyyy-MM-dd_hh-mm-ss-tt}.jpg", DateTime.Now);

if (customer.Photo != null)
{
customer.Photo.FileName = name;
customer.Photo.FileContentAsBytes = imageBits;
}
}
}

 

Any sample code or suggestions regarding how to solve this issue will be very helpful.

 

Thanks,

Pratik

 

 

From: SeanMcAlinden [mailto:notifications@codeplex.com]
Sent: Wednesday, December 01, 2010 7:19 PM
To: Pratik D. Kothari
Subject: Re: GetAll() doesn't get all the items [RapidRepository:235439]

 

From: SeanMcAlinden

Hi Pratik,

Ive started a new discussion thread for discussing the views - http://rapidrepository.codeplex.com/Thread/View.aspx?ThreadId=236790

Let me know how you get on.

Kind Regards,

Sean.

Read the full discussion online.

To add a post to this discussion, reply to this email (RapidRepository@discussions.codeplex.com@discussions.codeplex.com)

To start a new discussion for this project, email RapidRepository@discussions.codeplex.com@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com