Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7457939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:23:10+00:00 2026-05-29T13:23:10+00:00

I have an ASP.NET web site that has a entities version 4.0 DAL. I

  • 0

I have an ASP.NET web site that has a entities version 4.0 DAL. I have several pages that have texts boxes where you can enter data, and gridview to see and edit that data. I am using LINQ to write the insert logic in the code behind file for one of the pages. However, I would like to implement a BLL(business logic layer) so that I can use this code in several places and only make modification in one place. Anyhow, I need to call these BLL function for a particular table in code behind and I want to attach them to EntityDataSources using the GUI of visual studio. I have managed to make a separate class file to write my custom logic, but I can’t see to make the functions within the BLL file appear in the drop down of the EntityDataSources when I am using the GUI to pick separate update, insert, and delete functions. Am I decorating the functions in the BLL with the wrong property? Below is my attempt to make it work.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyTestModel;

/// <summary>
/// Used as custom logic for running queries againts the Location table
/// </summary>
public class LocationBLL
{
    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
    public IQueryable<RnLoc> viewLocation(string name)
    {
        MyTestEntities db = new MyTestEntities();
        var L = (from a in db.Location
                   where a.Location == name
                   select a);
        return L;
    }

    [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, false)]
    public bool InsertLocation(string location, string longName, string comments, bool active, bool current)
    {
        MyTestEntities db = new MyTestEntities();

        Location L = new Location();
        L.Location = location;
        L.LongName = longName;
        L.Comments = comments;
        L.Active = active;
        L.Current = current;

        L.Edited = DateTime.Now;
        L.Created = DateTime.Now;
        L.EditedBy = "EIC";
        L.CreatedBy = "EIC";
        L.AreaID = 1;

        db.AddToLocations(L);
        db.SaveChanges();

        return true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:23:10+00:00Added an answer on May 29, 2026 at 1:23 pm

    OK, so I seemed to have answered my own question. On our recent project we were using a Dataset not the entity framework, so when we made gridviews we attached them to ObjectDataSources, and the code above would provide the business logic that would be selectable within the ObjectDataSources. Also, the code was a bunch of functions involving table adapters. In this new project using entity, I was using an entityDataSource for the grid view and figured it was the replacement for an object datasource. So the solution was to use again ObjectDataSources, and use the code above which manipulates the entities. I’m still not sure if this is proper coding, but its working for now.

    Edit: The only thing bad about using business logic with the entity framework is that when you bind things like gridviews to ObjectDataSources that call on business logic, you have to disable Paging and Sorting. I have found that if you want paging and sorting you have to add a bunch more code to the business logic so it sorts and pages server-side verses the client side sorting that was supported with table adapters. Quite a pain, but probably better for performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old .net 2005 web site that has some asp pages and
I have an old school ASP (note: not ASP.NET) web site that has a
I have a product admin web site that has been generated using ASP.NET Dynamic
I have a asp.net web site that was developed on the .Net Framework v2
I have a web site that runs both classic ASP and ASP.NET Webforms. The
I have a web site in asp.net that uses a master page. In this
I have a very basic ASP.NET web site. It has a single page (TestPage.aspx)
I have an ASP.NET site that I am maintaining. Currently it has code that
Visual Studio 2008 .Net 3.5 C# I have a web site that has a
We have a legacy ASP.NET web site (not web application, so I can freely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.