This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, In my app I have a collection of page entities and they can have a category but they don't have to have one. In the model designer it is setup so that categories have a collection of pages but the ref is nullable. The issue is that I want to get pages of a certain status by category. I don't want to call category.Pages as that would get all of the pages with that category and then apply my filter by status to them. I want to do an iquerable and add my status filter to that. I have an extention method that will get the pages as Iqueryable (a workaround suggested by you guys on the forums). However if I call it I get an error
The binary operator Equal is not defined for the types 'System.Nullable`1[System.Int32]' and 'System.Int32'.The code on the category class: partial class Category |
|
|
Is the Status property on your Page entity nullable? From the error message that appears be the source of the error. If so you will want to add a check for this e.g. where (p => p.Status != null && (p.Status == 1 || p.Status == 2))
Jeremy |
|
|
Ignore the above - Ivan has just mentioned he has reproed the issue as you have described above so he is currently working on a fix.
Jeremy |
|
|
...and it's done. The fix will be in the next nightly build. As an interim workaround, you can change your Pages method to something like: return unitOfWork.Query<Page>().Where(p => p.CategoryId == category.Id); Note that this workaround would require you to change the Pages() method to take an IUnitOfWork, and pass this explicitly from GetLivePages() (because Entity.UnitOfWork is protected so you can get at it from within GetLivePages() but not from within Pages()). You can change it back once the fix arrives of course! |
|
|
thanks this worked by the way |
|