Welcome to the CodeSmith Community!

New User: Want to create DAL using Codesmith

Support Forums

Feel free to ask any questions about CodeSmith here.

New User: Want to create DAL using Codesmith

Answered (Verified) This question is answered

I have a need to create the DAL & BLL for my project.  I used the BusinessObjectTemplate PLINQO=>  (Database -> Other ->CSharp ->BusinessObject ) to create the BLL

I need to create the DAL. I need a template that create something like the following: Can you suggest a template?

[DataObject(true)]
public static class CategoryDB
{
    private static string GetConnectionString()
    {
        return ConfigurationManager.ConnectionStrings    ["HalloweenConnectionString"].ConnectionString;
    }

    [DataObjectMethod(DataObjectMethodType.Insert)]
    public static int InsertCategory(Category category)
    {
        SqlConnection con = new SqlConnection(GetConnectionString());
        string ins = "INSERT INTO Categories "
            + " (CategoryID, ShortName, LongName) "
            + " VALUES(@CategoryID, @ShortName, @LongName)";
        SqlCommand cmd = new SqlCommand(ins, con);
        cmd.Parameters.AddWithValue("CategoryID", category.CategoryID);
        con.Open();
        int i = cmd.ExecuteNonQuery();
        con.Close();
        return i;
    }

    [DataObjectMethod(DataObjectMethodType.Delete)]
    public static int DeleteCategory(Category category)
    {
        .............
    }

    [DataObjectMethod(DataObjectMethodType.Update)]
    public static int UpdateCategory(Category original_Category,
        Category category)
    {
        ...............
    }

 

  • Post Points: 35
Verified Answer
All Replies
Page 1 of 1 (4 items)