Mvc - Using The Repository Pattern
Feb 23, 2011
I am using the Entity Framework with POCO's generated using the T4 Templates. I have the generated classes in a separate assembly. Ok, so a very simple example: I have a Category entity in the model which has SubCategories (1-Many with SubCategory). When I use the following code, I get The ObjectContext instance has been disposed and can no longer be used for operations that require a connection. [Code]
View 2 Replies
ADVERTISEMENT
Nov 16, 2011
I have the following tables
Public Class Tag
<Key()> _
Public Property TagID As Integer
[Code].....
I implemented the repository pattern.
Now i have a list of Tags which contain the right TagReferences, but the tags may not be deleted, it's the TagReferences.
Variabels = ReferenceValue,ReferenceID
IEnumerable(Of Tag) = TagRepository.GetMany(Function(el) el.Reference = ReferenceValue And el.TagReferences.Any(Function(bl) bl.ReferencedID.Equals(ReferenceID)))
How can i remove all the TagReferences which contain the ReferenceID in one line?
View 1 Replies
Aug 29, 2011
This is the original code in c#
public class CategoryRepository: RepositoryBase<Category>, ICategoryRepository
{
public CategoryRepository(IDatabaseFactory databaseFactory)
: base(databaseFactory)
[Code]...
Does anyone has an idea what i should change to let it work and let my UserRepository use the methods in RepositoryBase while implementing the IUserRepository?
View 1 Replies
Mar 16, 2009
I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I use NHibernate to do the work on my business entities. For example:
[code]...
However, on my User class I have some properties and collections of other objects that ideally I'd like to be lazy loaded. But of course, the ISession is created and disposed within the repository, which I guess is why, outside of that, when I try to access those properties I get a "Could not initialize proxy - no Session" error.Is my only option then to disable lazy loading when using repositories? Or is it possible (or just foolish) to somehow get the session into scope in the business layer?I do like the repository model, and NHibernate is growing on me (after lots of initial frustration trying to make it work), so what's the best way you gurus have found of using them together?
View 1 Replies
Aug 1, 2010
I was wondering if there are any good vb.net code repositories around where people share code they have written, widgets they have developed, classes developed? I hate re-inventing the wheel.
View 3 Replies
Jun 12, 2010
In my project I have it set up so that all the tables in the DB has the property "id" and then I have the entity objects inherit from the EntityBase class using a repository pattern. I then set the inheritance modifier for "id" property in the dbml file o/r designer to "overrides"
Public MustInherit Class EntityBase
MustOverride Property id() As Integer
End Class
Public MustInherit Class RepositoryBase(Of T As EntityBase)
[Code]...
however produces the error "Class member EntityBase.id is unmapped" when i use VS 2010 using the 4.0 framework but I never received that error with the old one.
View 1 Replies
Aug 6, 2009
I have two tables, Clients and Administrators, which are linked in a many-to-many relationship by the table ClientAdministrators. In the real application this works fine and I can get a list of Administrators for my Client. My problem comes in trying to unit test the service class that is retrieving this from the repository. I have a FakeRepository class which implements my repository interface and I have several internal lists of objects for the service class to query against.
[Code]...
View 3 Replies
May 29, 2009
SubSonic 2.2. I use the repository record pattern, with a table "appointment" with an appointmentId as auto-incrementing int. I am trying to update it, but when I do update the fields with something totally different, dirty columns are always zero, and I get an exception.
[Code]...
View 1 Replies
Oct 27, 2009
The File Class has methods for sending/receiving (CopyTo and Overwrite) binary data to/from the File Repository Server (where files like Crystal Reports are stored), both of which have an overload that supports 'Binary data (safearray of VT_UI1)
View 1 Replies
Mar 23, 2010
I didn't see a question on this subject in the archives, so here goes: For those of you experienced Mercurial users, is this a correct .hgignore file to tell VB.Net Express to ignore files/sub-dirs when adding items in a new repository?
[Code]...
View 1 Replies
Feb 23, 2010
I have a generic repository that I communicate with my object context with. My object context has function imports that I want to be able to call through my generic repository. Currently I call them through an "Execute" function, but this is not ideal because I have to pass in my function name and parameters as strings which can cause run-time exceptions. My function imports map to complex types.
Is there a way to do something similar to:
Dim rep As IRepository(Of ComplexType)
Dim type As ComplexType = rep.Find(where:=Function(t) t.FunctionImport(parm, parm)).First()
Here is my generic repository as is:
[Code]...
View 1 Replies
Sep 1, 2011
I have a "MenuService", which uses an "MenuRepository".When the MenuService is created, it loads correctly with the MenuRepository.Then it wants to save it in the UnityControllerFactory, but the MenuRepository in the MenuService is Nothing then (it wasn't before).Some additional info:I'm using the Unity and Repository pattern.The problem happens with a partial view (for a menu), which i have included in the "HomeController", it could be relevant information, so i included this, just in case:
Function Menu() As ActionResult
Return PartialView("~Views/Shared/_Menu.vbhtml", _MenuService.GetAllMenuItems)
End Function
Also, my partial "menu" view is like this:
~/_Menu.vbhtml
@ModelType IEnumerable(Of FacturatieMVCv2.Domain.Slave.MenuItem)
@*<div id="myslidemenu" class="jqueryslidemenu">*@
[code]....
And i'm calling the partial view with:
@Html.Action("Menu","Home")
View 1 Replies
Aug 25, 2011
we have a CollabNet Subversion Edge server running on a Windows server. Subversion Server is configured to serve via https. When trying to import a Visual Studio project folder with TortoiseSVN it hangs when adding the project file (.vbproj). Test 1: It happens exactly the same when the server is configured to serve via http.Test 2: Importing any project folder using the console utility (svn) works fine.
Both these tests lead to the conclusion that there is neither a network nor authorization problem.
View 1 Replies
Jul 20, 2011
I have a utility that checks various file info (size, date, location, etc) against a manifest to see that it all matches. Would anyone know if there's a way to get the last write date of a file in a svn repository, using VB.NET. The equivalent of using FileInfo.LastWriteDate.
View 1 Replies
Sep 8, 2009
Private someSub()
If someBoolean = True Then Exit Sub
' do some great work because someBoolean is False
End Sub
I know there is a name for this. The idea is to check something and if it isn't what you want then you stop code processing. I thought it was called "escape pattern", but Google isn't confirming that name.
View 4 Replies
Jun 22, 2009
when should a trigger in your head go off signifying "Aha! I should use the factory pattern here!"? I find these moments will occur with many other design patterns, but never do I stop myself and think about this pattern.
View 6 Replies
Nov 9, 2009
i got this var: dim myvar as string
[Code]....
(Someone know how insert this ==>"<== into a var ? In PHP i use " ex: myvar = "Console.Writeline("hii")" but didnt work in vb net, how do it ?)
View 4 Replies
Aug 9, 2009
How to use MVC Pattern efficient?
View 8 Replies
Mar 21, 2012
How would I remove an alpha-numeric sub string in a string that meets these rules:
J111DD
L###LL
l = Leter
# = Number
View 1 Replies
Jul 23, 2010
I am normally a c# programmer but am now working in VB for this one project when I use to set up a singleton class I would follow the Jon Skeet model
public sealed class Singleton
{
static Singleton instance = null;
static readonly object padlock = new object();
[code]....
I get StackTracker.Instance.Instance and it keeps going, while it is not the end of the world it looks bad.is there a way in VB to hide the second instance so the user can not recursively call Instance?
View 1 Replies
Jan 11, 2011
When are predicates appropriate and what is the best pattern for usage? What are the advantages of predicates? It seems to me like most cases where a predicate can be employed a tight loop would accomplish the same functionality?
View 3 Replies
Jan 3, 2010
I have data like this in text file
202103
20204
20210
202110
I want to change the above data to be like this
(2 2.50 03.0)
(2 2.00 04.0)
[Code]...
View 2 Replies
Apr 22, 2009
I have text like following example
XXZZXXXZXXZXXXXZZZZZZXVVVVVXZVZ
and also I have two patterns like XX and ZZ I want to find longest possible string which include above given two patterns and return starting and finishing index of the array.
View 3 Replies
Jul 31, 2010
How do i find a pattern in richtextbox?[code]...
View 2 Replies
Aug 1, 2010
I want my app to look for a byte pattern in a process and return the first memory address of that byte pattern. I know I should use ReadProcessMemory and a loop, but I don't really know how to create a function for that,
View 2 Replies
Mar 17, 2011
validating a 9-digit number.
CANNOT BE -----------
000000000
111111111
[code]....
I had just managed to get the first piece done -- "^(??!0+|1+|2+|3+|4+))d{9}$"
View 1 Replies
Nov 3, 2011
I have a contextStrategie :
Shared Sub New()
If ConfigurationManager.AppSettings.GetValues("Context").ToString = "Custom" Then
_context = New CustomHandler
[code]....
I'm trying (for test purpose) to obtain the name of the class used for my instance :
Dim context As ContextStrategie = New ContextStrategie()
'what I tried :
test.InnerText = context.GetType.Name
What I tried return ContextStrategie, which is useless to me.obtain either CustomHandler or XMLHandler?
View 1 Replies
Nov 5, 2010
ok what i'm trying to do is make a pattern generator. i will have to do some substuutting too.ex:i wand to make A=1,B=2,C=3 ect.......the pattern is 3,3,2,3,3,3,2and say i make a button called "E" when i click that i want the patter from e since E=5 in the textbox it shoud come up "E,F,G,H,I,J,K,L" up to 8 thats all i want is it possible
View 17 Replies
Jul 5, 2010
I am working on creating a customized UI composite control. This control would be a container to several other custom controls.As a first step, i am creating the container UI using a singleton pattern. This is because at any point in time only one isntance of this container is allowed to be created. This is fine.Now i want to practice interface based desgin. So i introduced a sinple interface calleD IdesignSurface which has two properties. I would like my singleton class to implement this interface,so i tried something like this and got an error saying "end of line
NotInheritable
Class DesignSurface
implements IDesignSurface
[code]......
View 2 Replies
Oct 16, 2009
Im trying to Implement the Singleton Pattern and im wondering if this is "Thread Safe" or if I am going to have to explicitly perform a SyncLock on the object instance? Example:
Public NotInheritable Class SingleTon
Private Shared _singleton As SingleTon
Private Sub New()
[Code].....
I tried it both ways, using the SyncLock and without, just not sure which one to be using?
View 18 Replies