.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Advice on repository and ef4

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :ASP.Net


I'm currently working on a new project at work that's built with MVC 2 + EF4 and I'm still fairly new to EF4. I have several repositories for different things and they all follow a pretty similar pattern.

I've follow the video tutorials from Rob Conery Storefront Series, read though peoples blogs but I have a few issues with the way I have implemented the repository methods.

I use POCO's (at least I think they are, POCO's and DTO's seem quite close in comparison) in my application and I have a UI, Service and Data layer.

Before entities I used to use SqlDataReader and create POCO's and populate the values from the results then return a list or object but was getting annoyed by having to manually write SQL, add parameters and do all the left right mapping.

Now I use LINQ to select my data and AutoMapper to map it to my POCOs.

A Typical POCO looks like this:-

    public class LeadSource
        public int Id { get; set; }

        public int CompanyId { get; set; }

        public string Name { get; set; }

        public string Notes

View Complete Post

More Related Resource Links

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

New off line application working with sdf file. Need advice


Hey Folks

I am working on a project currently where I need to get data out of a 3rd party vendor's software that uses a .sdf file I looked this up and its a SQL CE file. I was hoping to just link to with with access but thats apparently not going to happen. I need to link to the database extract data from it to a csv file for later use. I also and most important I need to get the data from it and create a report that can be printed while on a customers site that my or may not have web access so I need for this program to be on and off line. I had my webapplication that I have been working on open and was able to bring up the sdf file under the server exploere however I can't seem to get anything out of it when I try to do grid views or detail views errors out.

Can I use one of Visual Studio projects to create this sort of applicaiton if so what would be the best approach. I would love to get an access odbc driver since office is allready installed on the employee's laptop's



build repository from SQL 2005? for a Linq, Jquery autocomplete



  I have the a question am going about his correctly I have a database for categories, it has many fields and about 4000 records,  but with a Jquery autocomplete needing speed and the fact that I only need to return a key and category name. I did the following:  (oh just to note, MVC2, Ajax project)


    public class categorySearch
        public Guid Category_GUID { get; set; }
        public string Category_Name { get; set; }


and now for the repository

    public class categoryRepository
        internal List<categorySearch> FindCategory(string searchText, int maxResults)
            List<categorySearch> category = new List<categorySearch>();
            dbWebEntities storedb = new dbWebEntities(); 

            var getcat = storedb.Categories.ToList();

            foreach (var item in getcat)
                category.Add(new categorySearch { Category_GUID = item.Cat_GUID, Category_Name = item.Category_Name});

            var result = from c in category
                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name

Metadata: Create a Database Schema Repository with Meta Data Services in SQL Server 2000


SQL Server 2000 Meta Data Services is a repository technology that stores and manages metadata for SQL Server. Instead of building database schemas over and over, Meta Data Services allows you to freeze an entire schema for use in other projects. You can also use these schemas for training, testing, or debugging. In this article, the authors will review the various components of Meta Data Services and show how it can be programmed using a Visual Basic client, XML, and XSLT. They will also show you how to manage and manipulate your metadata by generating a simple database schema using a SQL Server repository.

Alok Mehta and Ricardo Rodriguez

MSDN Magazine May 2003

Generic Repository in EF4 and MVC



I created a generic repository for a EF4 context in MyProj.Domain.

Now I have services with methods like FindById, FindByUsername that use the repositories.

My controllers use these services. 

Should I do the Mapping from Entities to View Models inside the services or in the controller?

The problem is for example, I might have UserEditViewModel and UserSignInViewModel.

In both cases I would need FindById.

So I might use UserService.FindById(id) in the controller and then map it to UserEditViewModel or UserSignInViewModel.

Or the other way around is to have two methods FindById in the service one returning UserEditViewModel and the other UserSignInViewModel.

I tend to do the mapping in the controller using AutoMapper so it is only a code line but I am not sure if this is the correct way.





using VS2010

using Net4.0

Need advice on starting ASP and eCommerce programming

hello group,I'm about to start implementing an e-commerce using ASP.NET and C#. However, I'm moving from PHP to .NET platform, of course in past have done C# programming. I have few questions;Where to start? is only ASP.NET that I need to catch up with or other topics as well?How can I use an e-commerce template i.e. nop-commerce or ... such that I can write/read to/from a different database other than MS SQL Server?How can I learn to tie nop-eCommerce with my ASPX pages ? is there any reference that I can use to learn it or is it part of the documentation which come with online store API?Thanks in advance.

Any advice on stopping the follwoing hacker (Meher Assel)

 Hi, All    I a have just logged into my hosting provider and all 3 of my sites have been hacked by the same perspn (Meher Assel). Has anyone came across this person before and any advice on how to stop it. All it looks like has been done is files created in my directoty saying I have been hacked on my hosting provider. Many Thanks Kered

Managing the SO-Aware Repository with PowerShell

As Jesus mentioned in this post, SO-Aware provides three interfaces for managing the service repository. An OData API in case you want to integrate third applications with the repository. OData is a pure http API that can be easily consumed in any platform using a simple http client library. The management portal, which is an ASP.NET MVC user interface layered on top of the OData API and probably the one most people will use. And finally, a PowerShell provider that also mounts on top of the OData API to allow administrators to automate management tasks over the repository with scripting.  The SO-Aware PowerShell provider, in that sense offers around 40 commands that enables simple management scenarios like registering bindings or services or more complex scenarios that involves testing services or sending alerts when a service is not properly working.   This provider can be registered as an snapin in an existing script using the following command, $snapin = get-pssnapin | select-string "SOAwareSnapIn"if ($snapin -eq $null){ Add-PSSnapin "SOAwareSnapIn"} Once you have registered the snapin, you can start using most of the commands for managing the repository. The first and more important command is "Set-SWEndpoint", which allows you to connect to an existing SO-Aware instance. This command receives the OData service location as first argument, and it looks a

SSAS 2008 Metadata Repository data - User Knowledge base

Hello, We have the SQL Server 2008 Analysis services instance with some databases, cubes, Dimensions, Measure groups, partitions, etc. The business users are find difficulty to search for a particular measure. I mean, it is difficult for them locate a measure from the available cubes; again finding the respective Measure Group/ Folder is not an easy task for them. Also, they need to know the source system of a particular attribute in a dimension, formula for the calculated measure and etc. So, we have planned to develop a knowledge repository, which needs to store the business metadata for the SSAS databases. The user needs to be access this information using the SharePoint site and should help them locate and understand the data. The User Interface needs to be user friendly too. I need your valuable suggestions for the design of this system. Note: I have referenced the below articles http://dwbi1.wordpress.com/2010/01/01/ssas-dmv-dynamic-management-view/ http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/c610850f-16b4-4eaf-9b91-a2d32816f40e

Please Advice SQL 2008 Standard Edition

·         I have a issue with subscriptions since we have SQL 2008 Standard edition and i found out that Data Driven Subscription are disabled. We have about 100 reports subscribed by our internal & external customers. I have a DB "Prices" In that we have 4 Tables, Analysts,Users,SalesReps & Sub Sales rep the subscriptions are by anyone and everyone from these 4 tables.... we have a Project thats in Build in sql server 2008, which is a repository for all our 100 reports....basically what we are trying to do is based on Relationship, security level and user hierarchy they can access the reports... Any ideas will help ???????????FM

Seeking Advice for Implementing Document Library Functionality

I have an assignment to implement a mechanism in WSS 3.0 to deliver files from a document library as PDF when the user selects a particular file.  I have a third party tool for PDF conversion which I can use to do the conversion, and I have put together some C# code for the API that does what I need as far as that goes. Where I am having trouble is deciding how to implement this in Sharepoint.  The multiple steps involved in kicking off a workflow would confuse many users, especially those not used to Sharepoint.  I would like to find a solution that would involve a single click on the chosen document. I know my way around ASP.NET, but Sharepoint is less familiar.  I am not afraid to jump in, and am not asking anyone to write code for me, but I am trying to get traction on the Sharepoint road.  I would appreciate any thoughts others have as to a direction I might take. Thanks.

Advice needed on backup strategy and implementation

This is my plan: Full database backup is performed at 5AM every day. Then log backups are taken every 30 minutes starting from 5:30AM till 11:30PM What I want to achieve is to have all backups for the same day to be contained in the same file on the disk. That is on Feb 18 2010 file c:\db_backup_02_18_10.BAK will be created at 5AM with full database backup. All backup logs that occur on Feb 18 will be appended to the same file. Next day c:\db_backup_02_19_10.BAK will be created at 5AM. Is this "correct" approach? The reason I like it is that everything needed to restore to any point in time for specific day is contained in one file and can be copied easily to a different computer. I tried to achieve this result via Maintenance Plan wizard by creating one task for full backup (scheduled once a day at 5AM) and another task for log backup (scheduled every 30 minutes starting from 5:30AM till 11:30PM) (both tasks are in the same maintenance plan). This, however, saves result from each job in a separate file called $DBNAME_backup_YYYY_MM_DD_HHMMSS_NNNNNNN.trn (for transaction log backup; will probably have extension .BAK for full backup) Can this even be done via Maintenance plan? I think I can achieve desired result via SSIS where I can generate file name programmatically and pass it as a parameter to "BACKUP DATABASE ..." or "BACKUP LOG ..." stat

need advice on a schema

I've inherited an ancient Access database that I've migrated to MS SQL. Have a question about how to improve a particular table.The table contains records for lodging establishments. Each row represents a particular establishment, and there are dozens and dozens of columns. Among these columns are over a dozen that name various activities available in the area where the establishment is located. Each activity has its own separate column, and the values are set to true or false. I sense there is a better way to handle this.The table will be queried with a web form, and among the form components will be checkboxes for each of these activities. What would be the best schema for the table? Should I create another table for activities (each activity being a row), and join it to the original table?Or is there a smarter way to handle this? I have not been asked to make any changes but this seems like a good opportunity to improve the database (and learn some things myself about how to design a relational database properly). Here's the schema of the existing table (I've imported it from Access into SQL 2005 but haven't altered anything yet): USE [maineinns_staging] GO /****** Object: Table [dbo].[MaineInnMembers] Script Date: 08/25/2010 14:31:45 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[MaineInnMembers]( [ID] [int] NOT NULL,

Need advice to control Privileges based on User

I'm a WinForm beginner. My main form is frmMain.cs Once user logged, frmMain.cs will display a menu based on User. This menu represent in button. Let's say, if User=System Admin then 3 button appear. if User=Master Agent Administrators then 5 button appear and so on How to control that? Really need advice If there's another way, please let me know

Advice on Data from Data - SQL VB.NET

Could on I get some advice on how to properly write / retrieve, in VB.NET / ASP.NET Page,  from SQL. It's not so much the 'writing' part for SQL that I am worried about.  I'm having some trouble retrieving data properly. I have a routine that runs each time the page is loaded, or an insert is performed (2 button, virtually the same process), post back occurs. When the page loads getTheSavedData - could be empty (recordSet) display 1 Record (recordSet) - that is based upon the getTheSavedData or lack there of   My difficulty is that, my second recordSet isnt getting the parameters expressed from the first recordset.  The saved information has an impact on the 2nd recordset / query. It can more or less be summarized in this Procedure. (excuse the clutter, I've been working with a few things, trying to display it on screen for myself)Private Sub a1TrialData() Dim a1IDCBDsaved As Integer = 0 Dim a1IDPBDsaved As Integer = 0 Dim a1IDCBDremaining As Integer Dim a1IDPBDremaining As Integer Dim SQLCount As String = "SELECT * FROM MER_ASS_QA WHERE U_ID = " & _ Merit3.passVariables.AUIDp & " AND A_Priority = " & _ Merit3.passVariables.aPriorityP & "AND TRIAL_NUM = " & _ Merit3.passVariables.aTrialNumP Dim strSQL

advice needed on implementing a re-usable class (c#)

Hi guys,Im trying to create a function for my website that allows the re-sizing of images for different purposes. I want the function to use variables for image height and image width, and obviously for the file itself. I have working test code for re-sizing a selected image that is hard-coded into the function. I have created it in a separate class in my App_Code folder, and have tried calling it on web pages and it works until I try and pass a filename as a variable, encountering a variety of errors. Should I be using a server control/user control to do this? or do I need something else?RegardsPooleo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend