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;
}
}