Reserve Methods For The Data Mapper?

Feb 10, 2010

I have a situation where I have two assemblies - one called "business objects" and another called "data mapper". This is to allow me to swap out the data mapper if necessary with no change to business logic.

When loading objects from the database, there are certain methods and properties within these objects that it's convenint to allow the data mapper to access directly so as to simplify the process of construction. However, I'd like to make sure that these methods are only available to the data mapper - because otherwise you can guarantee that some developer will go and use them, short circuiting the business logic.

Even if I prefaced the method names with eg DatamapperOnly, I'd bet that someone would be stupid enough to use them "because we needed to get the application out in a hurry".

Can anyone think of any way to prevent this? For example, is it possible to create a custom <datamapperonly> attribute to be applied to methods which would cause the application to warn the developer at compile time unless the calling program implemented an interface called IDataMapper?

View 3 Replies


Similar Messages:

WCF / ASMX :: Enum Mapper - C# 3.5 / Easiest Way To Achieve Mapping Without Writing Tedious Switch Statements?

May 25, 2010

We are developing SOA based application using .NET 3.5 and WCF & WPF.

One common issue we are facing is mapping between WCF enum and WPF enums. We had to do mapping between WCF enums to WPF enums. Following is sample code

Switch(WCFServiceObject.Status)
{
Case WCFServiceStatus.Married[code]....

You can see that we have to do mapping WPF and WCF enums. Is there any easiest way to achieve this mapping without writing tedious switch statements? One way of doing this is using Dictionary, but apart from this, is there any good way? We have lots of enums for which have to do mappings.

View 1 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

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

Security :: Not Extending MembershipProvider Class And Putting All This Methods In Some Unique Class And Call Its Methods Then?

Sep 16, 2010

I am beginner in web applications development. I started one little project and host it on source forge "https://homoco.svn.sourceforge.net/svnroot/homoco". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:

1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.

2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.

3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.

I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.

View 3 Replies

ADO.NET :: Which Are Fetching Data Methods

Feb 10, 2011

1)usign execute scalar i will get 1st col and 1st row value.

2)using dataset i will get whole table.. if my stored proc has 2 queries then i will get 2 tables within same dataset.. i can reference therese using ds.tables(0).rows(value).

3)suppose i use a datareader then i will get multiple-rows. i want to know how to get these each separate rows coloumn values into variables. below is the reader aspx.vb

reader = cmd.ExecuteReader();
while (reader.Read()) {

4)what is it mean by data reader is forward only method of getting data.

5)why do we do readeritem.tostring()

6) can you tell me the basic how is this reader,ds,scalar works.i mean i know to use but donot know basics esspecially the dataadpapter.why do we fill it when using dataset.

View 3 Replies

Data Controls :: Share Data Between Multiple Action Methods Inside A Controller

Mar 17, 2014

I have one controller with 4 to 5 action method. In all action method i have to check some feilds from database. So to reduce the database query i want to save this data one time and then want to use that in all action method. I know about tempdata and view bag but none of this can use in different action method, so how to achive this.

View 1 Replies

What Is The Difference Between Binding Data In Data Grid View Methods

Jan 3, 2011

What is the difference between binding data in data grid view methods ?

[code]....

and this second one

[code]....

View 1 Replies

Data Control Methods For Just One Record

Sep 20, 2010

I am making updatable pages for my website. I am new to asp.net so I want to find the best method to pull one record from the database. The record will consist of page name and page text. I have test information set up in the database which works of an ID and have constructed a database connection. But I want to use a database control which willl have minimum overhead for pulling out just one record. I won't require any features such as editing or pagination. I was thiking of using the data repeater.

View 3 Replies

C# - Methods Of Pulling Data From A Database

Dec 21, 2010

I'm getting ready to start a C# web application project and just wanted some opinions regarding pulling data from a database. As far as I can tell, I can either use C# code to access the database from the code behind (i.e. LINQ) of my web app or I can call a stored procedure that will collect all the data and then read it with a few lines of code in my code behind. I'm curious to know which of these two approaches, or any other approach, would be the most efficient, elegant, future proof and easiest to test.

View 3 Replies

.net - Methods To Save Data From JavaScript?

Mar 27, 2011

i work asp.net use web methods to save data from JavaScript when i press save the all page go the top how i can save state position after post back

View 4 Replies

MVC :: Can Call The Methods Inside The Controller And Inside The Models "Action Methods"

Mar 21, 2011

i have a repository class inside my model folder; this repositiry contains many methods , which are called from Action methods in the controllers; so my question is :- if i have a method insidle my model.reporsitory which calls a stored procedure, then can i call it an "action method"? or "action method" expression only apply to controller methods?

View 4 Replies

C# - LINQ Data Context Not Showing Methods?

May 11, 2010

For some reason my DataContext is not showing all the normal methods like SubmitChanges() etc in the intellisense.It also won't compile if I type in db.SubmitChanges();Any idea what I'm doing wrong? Normally I don't have this issue, I have several other projects that work fine...

View 1 Replies

JqGrid: Using Multiple Methods To Filter Data?

Oct 20, 2010

My requirement is to show a page with multiple filters to apply to grid data.

Suppose we are talking about Orders and an order has the following attributes

public class Order {
public int OrderID
public DateTime OrderDate
public DateTime ShipmentDate
public int OrderTotal
public int OrderStatus
}

Inside the jqgrid object I am showing all the attributes except the OrderStatus

The requirement is to create a view that has the jqGrid on the left part a panel on the right

Inside the right panel the user will see a list of checkboxes that represents every possible OrderStatus value and he want to search using both methods (for example selecting the checkbox "Shipped Orders" and then filtering the grid with Amount greater than a value)

I have already configured the advanced filtering (multiplesearch:true) inside the jqGrid object and I am able to create complex filters combining fields and logical operators.

how I can submit even the data from the right panel when the user press the search button?

Update 1:

Preamble: Oleg sample is fantastic but unfortunately does not fits requirements of my customer :(

@Oleg: I do not understand why you think that:

If the data are outside of the grid you will be show the order details on the right pane only for selected row. So the user will have not so good overview of the data.

maybe my description was not so clear but I am not going to show any order detail. To better clarify my requirement I have modified your sample to show you the desired final UI which is as in the following image:

The customer want to filter the data in the grid using two methods or both together:

Using the multiplesearch facilities provided by the grid itself (thanks for the workaround mention) Using the custom Search Panel (the one with the checkboxes on the right) provided

From a functional point of view the requirement is very easy to express: When the user click on a checkbox or make a search using the native multiplesearch I should post values to the server including also the checkboxes state.

To summarize I should:

Add the checkboxes state when a post is made through the native multiplesearch

Add the current multiplesearch state (if any) when the user click on a checkbox

View 2 Replies

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

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

MVC :: Methods To Passing Additional Data From Controller To View

Apr 29, 2010

I am getting started with Ap.net MVC. For that i chose to practice it by build an application. Im using MVC 2 and Linq To SQL, and i would like to passing another Query to the view. For example, i have this:

[Code]....

So i would like to pass data1 and data2 to the View. I can use return View(data1), but the View function accept just one data. So what technique i can use to pass the tow data to the view

View 5 Replies

Entity Framework - Connect Data Access Methods To UI?

Mar 2, 2010

I am seriously at a loss here. The three things that will not change in this project are the fact that we are using the Entity Framework to do our data access, the fact that we want thorough unit testing and that our UI is asp.net. My question is how the hell do you make this work in Asp.net? E.g. You can use an ObjectDataSource to connect a method to a control, but if this control is a FormView you have all these problems [URL] to deal with and it simply doesn't work.

Furthermore, with grids, you don't get paging or sorting out of the box unless you use an EntityDataSource which basically circumvents your entire application. I can't be the only person who cries at this. What do you do?

View 1 Replies

ADO.NET :: System.Data.TypedTableBase Methods Not Accessible Outside That Project

Oct 20, 2010

Presently we have converted a project from vs 2005 to vs 2010,

we have using typed dataset as our business object in separate project

after converting that dataset to vs 2010 dataset, datatable is been changed to System.Data.TypedTableBase<dataRow>,

because of that all project getting error saying method/properties not found default method/properties provided by datatable like select,rows, columns.. etc. are not able to access outside that project, but can be accessed with in that project.

View 1 Replies

"GroupBy" And "OrderBy" Methods From LINQ As Extension Methods?

Mar 11, 2010

We say that "GroupBy" and "OrderBy" methods from LINQ as Extension Methods.Then how about "variable.ToString()" and "string.Split()" menthods. Are these Extension methods.

View 2 Replies

Forms Data Controls :: Referencing Gridview By Name In Codebehind Methods?

Jul 23, 2010

I have a method I want to use on two gridviews which contain different information, ideally i want to do an if statement, something like

if (GridView.ID = "GridView_ABC") {
// do this
}
else if (GridView.ID = "GridView_2") {
// do this

}

View 6 Replies

Best Practice: General Asmx Data Loading Web-method Or Multi Web-methods

Apr 3, 2011

which is better approach from performance point of view, is it better to use one web-service method to load data by passing Database Table name and keys or is it better to use separate method for each database table! knowing that i'm using .net asmx through ajax requests.it's obvious that one method is better from OO perspective since it have one function type 'data loading' but what about performance? does IIS affected by that or not? also is it better to make multi web-services 'asmx files' or just one!

View 3 Replies

Forms Data Controls :: Nested Datalist And Ajax Tabcontainer Methods

Mar 18, 2010

I'm using nested datalists as per my requirement, in my second datalist i need to show data in tab panels. For that i placed ajax tabcontainer in my second datalist <Item Template> tags.when i'm trying to access tabcontainer activeindex changed event on my code behind, i'm getting an error . Below is my code..

[Code]....

View 2 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#: Can't See Methods In DLL - Why

Dec 9, 2010

I developed a DLL in C# When I am trying to call it I get: System.EntryPointNotFoundException: Unable to find an entry point named: It means that DLL doens't export any methods visible from DLL. Dumpbin doesn't show any methods either:

dumpbin.exe -exports ActiveXTest.dll
Dump of file ActiveXTest.dll
File Type: DLL
Summary
2000 .reloc
2000 .rsrc
2000 .text

What's wrong? The DLL looks ok.. according to documentation:

Csharp Code:
namespace Kosmala.Michal.ActiveXTest
public static void setHooks()
{
....
}
Here is how I call it:
Csharp Code:
namespace IWFHotkeyStarter
{
class Program
{
[DllImport("D:\work\iwf\_ctrl-tab-modless_dlg_testing\activex\VSProjects\AcriveXSourceCode\bin\Debug\ActiveXTest.dll")]
public extern static void setHooks();
static void Main(string[] args)
{
Program p = new Program();
p.run();
}
private void run(){
Console.WriteLine("run<<");
setHooks();
Console.WriteLine("run>>");
}
}
}

View 2 Replies







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