C# - Static Methods For Biz Layer?

Nov 18, 2010

Actually I have done all my Biz(business layer) and DAL CRUD Opprations using static methodes
and I just send my error messages to my log table a sample of biz layer

public static bool Delete(Guid LogGroupID)
{
using (DAL.ChroXEntities db = new ChroX.DAL.ChroXEntities())
{
var q = (from lg in db.LogGroupSet

[code]...

so what should i do to propagate an user friendly error to my users?

View 1 Replies


Similar Messages:

Architecture :: Use STATIC Methods In Data Access Layer?

Feb 4, 2011

I am developing a web application, which has Data Access Layer and this layer has only one class, in which all methods are static methods like static Insert, static Update, static Search. It has no properties. I am using these methods in my Bussiness Logic class for my users who are visiting my website.Now my question is : 1. Is it right to use static methods in this scenario ?2. What will happen if 10 users call Insert method at the same time ?

View 3 Replies

Architecture :: Impact Of Using Static Methods In Business Access Layer In 3 Tier Applciation?

Aug 25, 2010

is there any impact of using static methods in Business Access layer in 3 tier applciation,

View 4 Replies

Using Extension Methods In Static Methods On Extended Classes?

Aug 16, 2010

I have an extension method as follows:

public static class PageExtensions
{
public static int GetUserId(this Page targetPage)
{
var user = Membership.GetUser(targetPage.User.Identity.Name);
return (int)user.ProviderUserKey;
}
}

Now in a page I need to use this method in a static WebMethod, so I have added another 'extension method' to PageExtensions:

public static int GetUserId()
{
return (int)Membership.GetUser(HttpContext.Current.User.Identity.Name).ProviderUserKey;
}

and I call it as follows in my WebMethod: PageExtensions.GetUserId()

View 1 Replies

AJAX :: Calling Non-static Methods From A Static Method?

Jun 30, 2010

I did some research after posting. All I found was simple examples for no-layer architectures, like connecting to a database from your aspx page, so, in a corporate environment, it is unnaceptable.

I need to call a server-side method (using ASP.NET Ajax) in a 3-layer architecture.

For example, my Default.aspx contains a method LoadProducts().

[Code]....

[Code]....

This cannot change. There is no way to convert Business and Data layers to static.

How can I call the LoadProducts() method using ASP.NET Ajax?

View 2 Replies

Web Forms :: Cannot Debug Lower Layer Methods

Oct 27, 2010

I can not debug BLL and DAL methods VS doesn't step into those projects. Only I can debug UI project.

What's wrong with VWD express?

View 4 Replies

SQL Server :: Calling Methods From Data Access Layer?

Nov 15, 2010

I have created a table adapter in DAL. I have created a gridview in the page and want to fill the gridview with a table data by calling a method. My table has 11 columns but i want to display only 2 columns of the table. My getSong() method has a query as Select title, category from Muisc. But it diaplyas all columns with no data except title and category and the autoincrement primary key column with negative values. The pic is given below. How can i solve it?

View 2 Replies

Web Forms :: How To Access Session In Static Methods

Sep 15, 2010

I write a simple static method in my web page. How can i access session["id"] into method? I dont have access.For example:

public static void myFunc()
{
Session["id"]= 100;
}

View 2 Replies

C# - Making Cache Access Methods Static?

Nov 12, 2010

In ASP.NET, is there any reason not to make a set of functions that Add/Remove/Get from the Cache object Static?Get() - just gets the item, no reason not to be staticAdd(), Remove() - I've read that adding/deleting into the cache has it's own internal locking mechanism, so they can be static without me creating my own lock(){} wrapping.

View 1 Replies

Web Forms :: How To Access The Page Controls In Static Methods

Oct 4, 2010

How to access the page controls in Static methods.

View 2 Replies

C# - Best Way To Integrate Dependency Injection Using Unity When Static Methods Are Used?

Mar 8, 2010

Im faced with an impending upgrade to an ASP.NET site and I am thinking of introducing DI using Unity. I have researched the ASP.NET DI side of things and have 2 options (Global.asax or IHttpModule). Im happy to use either. As always, there is a legacy object model in place that I would like to upgrade/change. I would like to go down the route of Constructor injection (passing in the DAO) however, each object has a mix of static and instance methods that both currently call into the DB using SqlCommand objects themselves. I want this removed to provide DB independence, therefore can anyone suggest the best way to do the DI in this case? Im open to drastic changes if they are needed.

public class ExampleClass
{
public ExampleClass(int test)
{
TestProperty = test;
}
public int TestProperty {get; set;}
public int Save()
{
// Call DB and Save

[Code]....

View 1 Replies

Web Forms :: Difference Between Singleton Design Pattern And Static Methods

May 7, 2015

In one of the interview, I was asked why should we have to go for Single Design pattern, instead of just creating static methods. Because creating static methods also serve the same purpose, i.;e avoiding flooding of objects.

View 1 Replies

Alternative For Static Method In Interface - Enforce Implementing Class-level Methods

Oct 28, 2010

I have a hierarchy in my website project as below:

[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js

I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:

[code]....

where AddLinks method adds HtmlLink controls to Page.Header with href attribute set to coresponding css and/or js file.

I would like to add Interface that would force new controls to have AddLinks method but it is impossible since it is a static method. Because my custom controls inherit from Control class I cannot use abstract class and/or virtual methods either. How can I achieve my goal?

View 1 Replies

SQL Server :: "Adding Parameterized Methods To The Data Access Layer"?

Sep 6, 2010

em all new in C# and .NET.I am following this tutorial: [URL]And i am at step 3: Adding Parameterized Methods to the Data Access Layer - i have No problems in getting out all information from my database.But when i try to get a specific item by CategoryID i get a Error.This is what i type in my Query in the table adapter:

SELECT ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE CategoryID = @CategoryID

Here is the error i get when i click finish:The wizard detected the following problems when configuring TableAdapter Query "FillByCategoryID":

Details:
Generated SELECT statement.
Error in WHERE clause near '@'.
Unable to parse query text.

View 7 Replies

C# - Static Methods Updating A Dictionary<T,U> Is It Safe To Lock() On The Dictionary Itself

Dec 23, 2010

I have a class that maintains a static dictionary of cached lookup results from my domain controller - users' given names and e-mails.My code looks something like:

private static Dictionary<string, string> emailCache = new Dictionary<string, string>();
protected string GetUserEmail(string accountName)
{
if (emailCache.ContainsKey(accountName))
{
return(emailCache[accountName]);
}
lock(/* something */)
{
if (emailCache.ContainsKey(accountName))
[code]...

View 6 Replies

Architecture :: Using Static Methods To Build User Objects And Various Other Objects?

Jun 21, 2010

firstly a static class only ever exists once and is not an instance. Any static members (ie static int NoOfPeople;) is stored in one place and is shared between all sessions (like the old global variables).
Now static methods is where i'm not 100% sure. If I have a static method that doesn't use any other static members could this cause inconstant results, example (this is a fairly pointless method but just a quick example of the top of my head)

[Code]....

So in this example if two sessions (or threads) were to call this at the same time - would they both get back the expected results, because the method only uses private data (a, b and totalToReturn).Im sure this sounds a little simple but I will be using static methods to build user objects and various other objects that there will have to be a 100% garentee that the objects will not get mixed up between sessions and the wrong things return to the user.

View 5 Replies

Architecture :: How To Pass The Values From Presentation Layer To Business Logic Layer

Oct 26, 2010

I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.

For Example

I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.

View 3 Replies

Architecture :: Data Access Layer And Business Logic Layer?

Jun 24, 2010

I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:

public ProductBLL
{
public int GetProductName(string productId)
{
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);
[code]...

Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?

View 16 Replies

Architecture :: How The Data Pass From One Layer To Another Layer In Mvc Design Pattern

Apr 1, 2010

how the data pass from one layer to another layer in mvc design pattern...

View 2 Replies

MVC :: How To Make Business Layer Seperate From Presentation Layer

Feb 23, 2011

I've even got my JQuery Ajax submission going on now but I've encountered another problem. I *think* it's something to do with the structure I'm using but like I say, I'm fairly newo this.I have my AJAX form submission which builds my "PersonViewModel" (model for the presentation layer) in JSON and sends it to "@Url.Action("RegisterSubmit")" in my Person Controller. Now, I seperate my business layer from my View/presentation layer so in "RegisterSubmit"I'm verifying the model is valid then instantiating a new instance of my business model "Person", adding the values from "PersonViewModel" and then calling my "Save" function.

View 7 Replies

Business Layer Errors And Service Layer Handling?

Mar 7, 2011

We're building a large web app that has numerous layers. In order to communicate to the business layer we're using a service layer that the web layer calls when data is needed. Unfortunately, it seems that if exceptions are thrown in the business layer, it seems that the services on the web side are wrapping the exceptions and re-throwing them. We're looking for a clear way to encapsulate the error and log it, without WCF wrapping a new exception around the original.

View 2 Replies

MVC :: Custom Ex Class Be In The Repository Layer Or The Domain Layer?

May 6, 2010

My repositories throw exceptions (System.Exception) when some things go bad and I know this is bad practice.. so i will create a custom exception (DataException). My question is should this custom ex class be in the repository layer or the domain layer? Im thinking it should be in Domain layer where all business objects and repository interfaces live but just want to make sure.

View 3 Replies

C# - N-layer Business/service Layer Design?

Jan 26, 2011

I'm trying to reevaluate our n-layer architecture and would love to get some based on your experiences. Here is our typical .NET n-layer (sometimes n-tier) design.

Project.UI
Project.Services
Project.Business
Project.Model
Project.DataAccess

DataAccess typically consists of Entity Framework 4 and Repository classes. I attempt to follow the Aggregate Root concept in order to avoid having a repository for table, easier said than done in my experience. I tend to have ~70% match between Repositories and Tables.

Model usually consists of my Entity Framework 4 entities, I've been using Self-Tracking EF entities with success.

Business is what I struggle with the most. I typically have a Manager class for every Repository. This class will contain methods like .Add() which will perform business validation before forwarding down to repository.Add().

Services, typically I will only implement this if in fact I am looking to create a web service based solution. This layer will be tasked with marshaling requests/responses between DTOs and entities. And most importantly provide the more coarse grained interface. For example a TradingService.SubmitTrade(), which is really a facade for a business transaction which might include AccountManager.ValidateCash(), OrderManager.SubmitOrder(), etc.

My business layer is very entity centric, really it's just the glue between the entities and the repository, with validation in between. I've seen many designs where the Service Layer is what holds a reference to the repositories (in essence skipping the "business layer"). In essence it serves the same purpose as my Business layer, it does the validation, however its' responsibility (and naming) is a higher level, more coarse grained business transaction. Using the example above the TradingService.submitTrade() will not delegate to any business manager classes, it would itself query the necessary repositories, perform all the validation etc.

I like my design in a sense that I can reuse a business layer method in multiple service calls, however I hate the fact that for every repository I have a matching business layer manager, creating tons of extra work. Maybe the solution is a different type of grouping at the Business Layer level? For example combine individual Manager classes like PhoneManager and EmailManager (note I have Phone entities and Email entities) into a logical Manager class such as ContactsManager (note I don't have a "Contact" entity type). With methods such as ContactManager.GetPhones() and ContactManager.GetEmail(), etc.

View 1 Replies

Architecture :: How To Pass The Data Between Data Access Layer And Business Acces Layer

Jun 3, 2010

here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.

View 7 Replies

Web Forms :: How To Change This Methods In To Use Dictionary Or Extension Methods

Jul 23, 2010

public class CacheHelper { /// <summary> /// Removes object with the specified key. /// </summary> /// <param name="key">The key.</param> [code]....

I have this methods for caching..I need to change this methods to use in aDictionary<string,object>

How do I need to change this code Because I am new to asp.net I am still learning..

View 12 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved