Architecturehttp://forums.asp.net/16.aspx/1?ArchitectureDiscuss and debate ASP.NET application designs.Thu, 16 May 2013 23:31:34 -0400urn:uuid:00000000-0000-0000-0000-000000000016urn:uuid:00000000-0000-0000-0000-000005395231http://forums.asp.net/p/1906649/5395231.aspx/1?How+to+unit+test+repositories+containing+complex+queries+How to unit test repositories containing complex queries? <p>I have a question, if we push complex/multi table queries into the repository layer which I agree is where it should belong - how would you go about unit testing this logic without having a database?</p> <p>I might add, that normally I would have that when unit testing, you would implement a dummy IRepository, or mock the IRepository so that it would return your domain objects, and you would then unit test the controller classes with a mocked repository.</p> <p>However by pushing complex queries into the repository itself, it makes it difficult to mock - I mean you wouldn't want to reimplement your complex query logic in the mock, which really only leaves testing with a real database connected, which makes it an integration test</p> <p>Dave</p> 2013-05-15T23:33:55-04:002013-05-15T23:33:55.39-04:00urn:uuid:00000000-0000-0000-0000-000003899340http://forums.asp.net/p/1565615/3899340.aspx/1?WCF+vs+Web+ServiceWCF vs. Web Service <p>I was going to create a&nbsp;WCF service&nbsp;to consume in a client application.&nbsp; With the EXTREME compexity of WCF,&nbsp;I decided i better find out WHY I&nbsp;WOULD EVER USER SUCH A MESS!&nbsp; </p> <p>Can someone&nbsp;explain WHY a WCF service would ever be used instead of a&nbsp;web service.&nbsp; I don't really have time to attend all the training classes necessary to use WCF and with the months I have been attempting to create a single Hello World service and publish, &nbsp;I would really like to know if this can even be done or why would it be used?</p> <p>What a major cluster f&amp;%k.</p> <p>The Hello World basic out of the box service doesn't even work.&nbsp; How would you ever create one for use with actual functionality.&nbsp; The out of the box one creates a url with Design_Time_Addresses in it.&nbsp; When navigating to the address, you just get page not found.</p> <p>Sorry for the bad attitude.&nbsp; I've just wasted so much time on WCF with absolutely NO SUCCESS!</p> 2010-06-04T16:41:06-04:002010-06-04T16:41:06.933-04:00urn:uuid:00000000-0000-0000-0000-000005396096http://forums.asp.net/p/1906539/5396096.aspx/1?Application+health+check+ideasApplication health check ideas <p>I am interested in writing a health check app for our software. &nbsp;We do sql driven web based software and I am thinking of an app that checks:</p> <ul> <li>server status (version, errors in logs, etc) </li><li>iis configuration </li><li>web disk space </li><li>sql disk space </li><li>client's db version vs our expected db version </li></ul> <p>Are there any other things you all can think of that should be included? &nbsp;Our main issue in the past has been schema discrepancies. &nbsp;</p> <p>Thanks!</p> 2013-05-16T15:28:04-04:002013-05-16T15:28:04.49-04:00urn:uuid:00000000-0000-0000-0000-000005391683http://forums.asp.net/p/1905482/5391683.aspx/1?patternpattern <p>Hi</p> <p>does repository pattern suitble for MVC application has too many CRUD Forms?</p> <p>Thanks</p> 2013-05-12T19:47:23-04:002013-05-12T19:47:23.017-04:00urn:uuid:00000000-0000-0000-0000-000005391428http://forums.asp.net/p/1905427/5391428.aspx/1?Inject+HttpContextBase+from+Microfct+Unity+Inject HttpContextBase from Microfct Unity. <p>Hello every one. I am working on an architecture development module on mvc4 with EF5 using Code First.&nbsp;</p> <p>I have a project called IocConfig which contains the dependancy stuff like.</p> <pre class="prettyprint">public static void RegisterDependancyResolver() { //Create UnityContainer IUnityContainer container = new UnityContainer() .RegisterType&lt;IDBFactory, DBFactory&gt;(new HttpContextLifetimeManager&lt;IDBFactory&gt;()) .... .... .... DependencyResolver.SetResolver(new UnityDependencyResolver(container)); }</pre> <p></p> <p>here&nbsp; IDBFactory and&nbsp;&nbsp;DBFactory are my datacontext interface and its implemented class.</p> <p>I have registerd all of my service context interfaces and their implemented classes here. The problem comes, when I am registrering my authenticationService interface and its implementing class. Here is the code snippet for that</p> <pre class="prettyprint"> public partial interface IAuthenticationService : IBaseServices { // void SignIn(Customer customer, bool createPersistentCookie); //void SignOut(); Customer GetAuthenticatedCustomer(); } public class AuthenticationService : BaseServices, IAuthenticationService { private readonly HttpContextBase _httpContext; private readonly ISAWINCustomerService _customerService; private readonly TimeSpan _expirationTimeSpan; private Customer _cachedCustomer; public AuthenticationService( HttpContextBase httpContext, ISAWINCustomerService customerService, IUnitOfWork unitOfWork) : base(unitOfWork) { this._httpContext = httpContext; this._customerService = customerService; this._expirationTimeSpan = FormsAuthentication.Timeout; } /// &lt;summary&gt; /// Gets the authenticated Customer /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public virtual Customer GetAuthenticatedCustomer() { if (_cachedCustomer != null) return _cachedCustomer; if (_httpContext == null || _httpContext.Request == null || !_httpContext.Request.IsAuthenticated || !(_httpContext.User.Identity is FormsIdentity)) { return null; } var formsIdentity = (FormsIdentity)_httpContext.User.Identity; var customer = GetAuthenticatedCustomerFromTicket(formsIdentity.Ticket); if (customer != null &amp;&amp; customer.IsActive &amp;&amp; customer.IsRegistered()) _cachedCustomer = customer; return _cachedCustomer; } /// &lt;summary&gt; /// Gets the customer info from cookie /// &lt;/summary&gt; /// &lt;param name="ticket"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; public virtual Customer GetAuthenticatedCustomerFromTicket(FormsAuthenticationTicket ticket) { if (ticket == null) throw new ArgumentNullException("ticket"); var usernameOrEmail = ticket.UserData; if (String.IsNullOrWhiteSpace(usernameOrEmail)) return null; var customer = _customerService.GetCustomerByUsername(usernameOrEmail); return customer; } }</pre> <p></p> <p>I have registerd the above interface and implemention class to my IoCConfig file too. But when I create an instance of&nbsp; IAuthenticationService interface, its giving error, NO PARAMETR LESS CONSTRUCTOR DEFINED FOR THIS OBJECT. I guess I know the reason, but not able to solve it. I think creating the instance of &nbsp;HttpContextBase &nbsp;in&nbsp;&nbsp;&nbsp;AuthenticationService class in line,&nbsp; private readonly HttpContextBase _httpContext; &nbsp;is creating the error, since&nbsp;&nbsp;HttpContextBase is not registered in the IocConfig (Dependancy.). If I am commenting the the object of&nbsp; HttpContextBase, it works well. But I need that instance. So any one has any idea to how to resolve it.</p> <p>I am using the&nbsp;</p> <pre class="prettyprint">using Microsoft.Practices.Unity;</pre> <p>namespace.&nbsp;</p> <p></p> <p>&nbsp;</p> <p></p> <p>&nbsp;</p> <p></p> <p>&nbsp;</p> <p></p> <p>&nbsp;</p> <p></p> <p>&nbsp;</p> 2013-05-12T08:30:20-04:002013-05-12T08:30:20.243-04:00urn:uuid:00000000-0000-0000-0000-000005384085http://forums.asp.net/p/1903732/5384085.aspx/1?Using+Repository+Pattern+for+different+requirementsUsing Repository Pattern for different requirements <p>I have read a lot about repository pattern, however; a few things are still not clear to me. What I have seen so far is this:</p> <p>1. A base Interface <strong>IRepository</strong> (with some method signatures)<br> 2. Repositories implementing IRepository e.g. <strong>ProductRepository : IRepository</strong><br> 3. Each&nbsp;BO using the respective repository e.g. <strong>ProductBLL uses ProductRepository, EmployeeBLL uses EmployeeRepository</strong></p> <p>What really confuses me is that different BO have different requirements (Employee, Product, Address are all different with their own requirements). <strong>How do all repositories implementing the same interface (IRepository</strong>) meet their requirements. If we have the following case:</p> <pre class="prettyprint"><strong>interface IRepository</strong> // may use generics { GetByID (); GetAll (); Save (); Delete (); Update (); }</pre> <pre class="prettyprint">class ProductRepository : <strong>IRepository</strong> { // implementation }</pre> <pre class="prettyprint">class EmployeeRepository : <strong>IRepository</strong> { // implementation }</pre> <p>Now we may have the following requirement, how do we meet them?</p> <p>EmployeeReposiotry: GetEmployeesByAge (), GetEmployeesByAddress (); GetEmployeesBySalary();</p> <p>ProductReposiotry:&nbsp;&nbsp;&nbsp; GetProductByPrice (), GetProductByDate(); GetProductByMaxPrice(); GetProductByMinPrice ();</p> <p><br> <br> &nbsp;</p> 2013-05-04T10:22:37-04:002013-05-04T10:22:37.03-04:00urn:uuid:00000000-0000-0000-0000-000005389224http://forums.asp.net/p/1904945/5389224.aspx/1?SOLID+design+patternsSOLID design patterns <p>Hi</p> <p>I was reading about the “SOLID” design pattern, which states for example;<br> “a&nbsp;class&nbsp;should have only a single responsibility.”</p> <p>I am self-taught and until now have not been paying much attention to any form a design pattern.<br> If I were to apply such a pattern, how would it impact the design for example of my site’s Registration page.</p> <p>Currently everything is wrapped in one class “Account_Register”, with methods for the following:<br> -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Register the user<br> -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Connect to a CRM system to collect info regarding the Registered user and populate some Profile info<br> -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assign some roles for the user<br> -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Send a confirmation email</p> <p>Would it be a better design to use a separate class for each of these methods since they have their own “responsibilities”?<br> If so, would these classes be nested in my “Account_Register” class or should they fall outside of it.<br> If not nested, should they also be derived from the “System.Web.UI.Page” class?</p> <p>Thanks</p> 2013-05-09T12:56:55-04:002013-05-09T12:56:55.873-04:00urn:uuid:00000000-0000-0000-0000-000005386673http://forums.asp.net/p/1904327/5386673.aspx/1?design+of+a+intranet+application+with+workfllow+wwf+or+without+WWF+design of a intranet application - with workfllow[wwf] or without WWF ? <p>hi,</p> <p>I am having a requirement to design a service desk mgmnt solution using plain asp.net withs ql db as database. how to do this,</p> <p>ie, since this service desk mgmnt consists of task assignment and response and closing the tickets raised during the process.</p> <p>I am confused, Should i implement the asp.net with Windows Workflow Foundation to achieve the &nbsp;func.</p> <p>like employee raises a request and &nbsp;it will go to a moderator and based on the category[ like desktop allocation, install s/w,remote dekstop access, admin access for the machine &nbsp;etc etc] moderator will assign the task to his teammember[ called assignee : <strong>a role</strong>].</p> <p>assignee will resolve the issue and make changes to ticket's status &nbsp;as <strong> resolved</strong>. if he needs &nbsp;more info from user, he will make it as</p> <p><strong>&quot;user inputs needed&quot; </strong>and assign the task back to the employee who raised the ticket<strong>.</strong></p> <p>So,ultimately the ticket is resolved and task is assigned back to enduser or closure. so employee will click on the close button and &nbsp;ticket's life cycle is completed.</p> <p>now my doubt/question is whether should i go with WWF to implement the solution&nbsp;</p> <p>or</p> <p>simply i will create a task table and make changes to the table whenever theres &nbsp;is &nbsp;onclick of button &nbsp;happens from the employee or &nbsp;assignee or moderator and send &nbsp;notifications wherever necessary.</p> <p>so that i can track the same also in a tickethistory table for future purpose.</p> <p>if i go with asp.net&#43;WWF , how complex it is</p> <p>&nbsp;or what are the issues/problems i will be facing if i go with simple tasktable in my sql db and manage the ticket status.</p> <p>&nbsp;any help is highly appreciated.</p> <p></p> <p></p> <p><strong><br> </strong></p> <p><strong><br> </strong></p> <p></p> 2013-05-07T09:43:06-04:002013-05-07T09:43:06.07-04:00urn:uuid:00000000-0000-0000-0000-000005373421http://forums.asp.net/p/1901286/5373421.aspx/1?tool+measuring+code+complexitytool measuring code complexity <p>i am&nbsp;working on a&nbsp;.<b>NET</b> application which requires to measure complexity of the code. Has anyone idea&nbsp;about a&nbsp;&nbsp;tool&nbsp; which will help measuring complexity?</p> 2013-04-24T08:52:17-04:002013-04-24T08:52:17.88-04:00urn:uuid:00000000-0000-0000-0000-000005383566http://forums.asp.net/p/1903582/5383566.aspx/1?What+s+the+benefit+of+using+a+WCF+layer+between+the+presentation+and+the+data+layers+What's the benefit of using a WCF layer between the presentation and the data layers? <p>I see a lot of web applications use a WCF layer to relay the data between the front end and the back end like so:</p> <p>The asp.net front end always calls the WCF service layer.</p> <p>The WCF service layer calls the data access layer methods.</p> <p>In other words, the asp.net front end (either code behind or MVC controller) never directly calls to the data access layer.</p> <p>I guess the idea it to decouple the front end from the back end, just so changes in the data access layer will have 0 impact to the front end.</p> <p>But the question is that the WCF service layer is still tightly coupled with the data access layer, isn't it? Changes in the data access layer will likely have impact on the WCF service layer, correct?</p> <p>Any thoughts?</p> 2013-05-03T15:31:00-04:002013-05-03T15:31:00.937-04:00urn:uuid:00000000-0000-0000-0000-000005367676http://forums.asp.net/p/1899923/5367676.aspx/1?Validation+with+Business+ObjectValidation with Business Object <p>I am looking at a comprehensive 'Validation' handling mechanism which can be plugged into my business object. The BO must be able to validate itself. Some of the features should include the following:</p> <p>1. Rules can be added randomly (with some built in rules e.g. Required, Length etc)</p> <p>2. I may/may not choose to validate a field(s) in the BO depending on the requirement</p> <p>3. IMPORTANT: The same validation mechanism can be reflected at the Client-side</p> <p>I am aware of frameworks like CSLA.NET (which is quite huge to grasp) but would prefer to build my own.</p> <p>Any help is appreciated.</p> 2013-04-18T06:41:06-04:002013-04-18T06:41:06.957-04:00urn:uuid:00000000-0000-0000-0000-000005383908http://forums.asp.net/p/1903670/5383908.aspx/1?Repository+Pattern+advantage+Real+time+exampleRepository Pattern advantage - Real time example <p>Hello Team,&nbsp; I am new to design patterns and want to know the real advantage of repository pattern (In webforms, not in MVC). i have read in multiple articles it is easy to test, resuse etc.. but can any one provide with an real time&nbsp;example for easy testing , reuse and any other benefits</p> <p>And i want to compare the testing flexibility before and after repository pattern, please help</p> 2013-05-04T04:29:53-04:002013-05-04T04:29:53.347-04:00urn:uuid:00000000-0000-0000-0000-000005376923http://forums.asp.net/p/1902106/5376923.aspx/1?Which+is+better+to+use+for+Error+Handling+Try+Catch+Finally+or+Page_Error+Event+on+page+Which is better to use for Error Handling Try/Catch/Finally or Page_Error Event on page? <p>Which is better to use for Error Handling Try/Catch/Finally or Page_Error Event on page</p> <p>if I have 50 event on my page and around 100 functions on the page itself. so which is better to use, weather I have to use&nbsp;Try/Catch/Finally in each function and each event or can I use&nbsp;&nbsp;Page_Error Event on page</p> <p>Which is better, Performance/Security/Best Practices wise?</p> <p>Thanks in Advance</p> <p>Cheers</p> <p>Dinesh</p> 2013-04-27T09:10:06-04:002013-04-27T09:10:06.85-04:00urn:uuid:00000000-0000-0000-0000-000004361878http://forums.asp.net/p/1667628/4361878.aspx/1?3+Tier+architecture+in+ASP+NET3 Tier architecture in ASP.NET <p>Hi. I was tasked to create 3 tier web application. However, i browsed through many books &amp; tutorials. The examples are doing it using Object data source which my lecturers claimed that it is not 3 tier at all. Shouldn't be dragging any data source into deisgn view. Any&nbsp; comprehensive examples for me to take reference from?</p> <p>Seems that 3 tier architecture examples are very few. </p> <p>Thanks.</p> 2011-03-29T07:56:48-04:002011-03-29T07:56:48.25-04:00urn:uuid:00000000-0000-0000-0000-000005382325http://forums.asp.net/p/1903311/5382325.aspx/1?Repository+PatternRepository Pattern <p>Hi All,</p> <p>I have to design repository pattern for myweb application.</p> <p>I have&nbsp;two different database&nbsp;servers one is SQL server and other is SQL Azure. Database and database&nbsp;schema&nbsp;is same&nbsp;in both servers.&nbsp;So I have cereated&nbsp;an&nbsp;interface and gave two implementations( Repositories&nbsp;), one for SQL server and other for SQL Azure.&nbsp;After implementing I observed that methods written in both implemetations are same just connection string is different.</p> <p><strong>Thus resulted in a lot of duplicated code. How to&nbsp;design repository pattern considering above&nbsp;scenario&nbsp;to avoid&nbsp;duplicate code.</strong>&nbsp;</p> 2013-05-02T14:52:54-04:002013-05-02T14:52:54.527-04:00urn:uuid:00000000-0000-0000-0000-000005382055http://forums.asp.net/p/1903251/5382055.aspx/1?WebService+stateless+session+managementWebService stateless session management <p>Hi ,</p> <p>I am creating a webservice for that i have enabled session and at client i have used cookie container to mange the state of serivce side variable.</p> <p>Actually i m maintaining a Socket at service.But when i m accessing my service by multiple thread due to this cookie container my access to the service is very slow or you can call it as blocking when one of the thread continously accessing the service.</p> <p>for example :</p> <p>Threadbackgroung conntinously calling a function which is calling receive for socket.Another thread is for Sending request.</p> <p>My issue is when i m using Cookie container my service state is managed but apllication is slow.and if i m removing cookie container then my application is fast but session is not maintained at the service which will completely hamper my tasks.</p> <p></p> <p>Can I manage a socket variable at service without Cookie container.</p> 2013-05-02T11:14:11-04:002013-05-02T11:14:11.397-04:00urn:uuid:00000000-0000-0000-0000-000005380818http://forums.asp.net/p/1902964/5380818.aspx/1?How+is+Cache+different+from+data+in+DataTable+Does+it+have+a+performance+impact+How is Cache different from data in DataTable? Does it have a performance impact? <p>When page is loading, I am querying large amount of data and storing in Data Table. This Data Table is acting as a Data Souce to a GridView control.</p> <p>On PageIndexChanging event, I am rebinding GridView as below:</p> <pre class="prettyprint">GridView1.DataSouce = myDataTable; GridView1.DataBind();</pre> <p>I am wondering if I use Cache to store data instead of DataTable, will it be faster? Will the pagination be fast?</p> 2013-05-01T10:35:35-04:002013-05-01T10:35:35.947-04:00urn:uuid:00000000-0000-0000-0000-000005366604http://forums.asp.net/p/1899671/5366604.aspx/1?Return+data+from+DAL+using+Business+ObjectReturn data from DAL using Business Object <p>I would like to know that using business objects in a n-tier architecture, should the DAL return raw data (using DataSet/DataTable) or return a single/List of business objects - and WHY? For example, I have the following business object:</p> <pre class="prettyprint">class Employee { int ID, string Name, String Address }</pre> <p><br />Now I have two options at the DAL Level:</p> <p>1. </p> <pre class="prettyprint">public IList&lt;Employee&gt; GetAllEmployees () { IList&lt;Employee&gt; listEmployee; .... return listEmployee; } <strong>// Let the BLL return the same list back to the UI</strong></pre> <p>&nbsp;</p> <p>2.</p> <pre class="prettyprint">public DataSet/DataTable GetAllEmployees () { DataSet/Datatable myData; .... return myData; } //Let the BLL create a list of employees and return it to the UI</pre> <p>I personally think the DAL should return raw data (using some built in data container) since that what DAL means.</p> <p>Thanks.</p> 2013-04-17T11:01:51-04:002013-04-17T11:01:51.757-04:00urn:uuid:00000000-0000-0000-0000-000005364922http://forums.asp.net/p/1899282/5364922.aspx/1?Business+objects+and+performance+issuesBusiness objects and performance issues <p>I am using business objects aka DTO, smart objects in my application. I am concerned about the performance due to to database hits. Let us consider the following business objects:</p> <pre class="prettyprint">class InvoiceDTO { int ID; string RefNo; DataTime Date; EmployeeDTO emp; } class EmployeeDTO { int empID; string name; int age; Address address; }</pre> <p>Now suppose we have BLL &gt; InvoiceBLL &gt; GetAllInvoices (). The code will be something similar to the following (details ommitted for bravity):</p> <pre class="prettyprint">class InvoiceBLL { public InvoiceBLL () {} public IList&lt;InvoiceDTO&gt; GetAllInvoices () { IList &lt;InvoiceDTO&gt; invoiceList = new .... datatable = InvoiceDAL.GetAllInvoice... foreach DataRow row in datatable { invoiceDTO = new InvoiceDTO () invoiceDTO.ID = row ["id"] invoiceDTO.Date = row ["date"] invoiceDTO.RefNo = row ["refno"] <span style="text-decoration: underline;"><strong>invoiceDTO.emp = EmployeeBLL.GetEmployeeData (row ["employeeID"]) </strong></span> invoiceList.add (invoiceDTO) } return invoiceList; } } &nbsp;</pre> <p>In the above code, the highlighted row is where Employee data is being fetched for each Invoice which is a major performance hit. If we have thousands of Invoices then we have to make thousands of database calls to get the employee data for each invoice. Imagine where we have more nested objects within the same Invoice class. <strong> What would be a better approach to handle this situation. I am aware of LazyLoading but suppose we are binding a list of Invoices to a GridView where displaying employee data is essential. In this case, fetching Employee data for each Inoivce becomes essential. How do we handle the performance issue than?</strong></p> <p>Thanks.</p> 2013-04-16T04:33:10-04:002013-04-16T04:33:10.74-04:00urn:uuid:00000000-0000-0000-0000-000005371017http://forums.asp.net/p/1900723/5371017.aspx/1?Database+selection+and+design+Database selection and design. <p>hi,</p> <p>I have to design and select Database for Trading system,so which will be best?</p> <p>Considering that in that system every day millions of transactions is going to be happen?</p> <p>Please suggest me yor best ans with best solutions.</p> <p>&nbsp;</p> 2013-04-22T07:33:21-04:002013-04-22T07:33:21.05-04:00