CodeSmith Community
Your Code. Your Way. Faster!

Indexed Properties And Custom Stored Procedures

Latest post 08-01-2007 2:49 AM by MrBretticus. 3 replies.
  • 07-10-2007 4:07 AM

    • MrBretticus
    • Top 75 Contributor
    • Joined on 02-10-2006
    • Perth, Australia
    • Posts 54
    • Points 1,360

    Indexed Properties And Custom Stored Procedures

    This feature request is broken into two parts, the latter being dependant on the former:

    1. I've been thinking about how nice it would be if properties were indexed by name, e.g. MyEntity["Name"]. This would allow for easier use of entities in generic code, and would eliminate the need for using reflection to extract property values (e.g. EntityUtil.GetPropertyValue). I thought perhaps properties could be saved to a Dictionary<string, object> (whether the individual private members are kept or not). I've done some quick testing and there is minimal difference in speed over 100000 iterations.
    2. Built on top of this it would be fantastic if custom stored procedures always returned entities (and not a dataset etc.) and any extra columns simply got pushed into the index property list. I've seen a similar request before at http://community.codesmithtools.com/forums/p/4529/18519.aspx.
    Of course to keep everyone happy both of these features could be configurable.

     

    Cheers, Brett "Most human beings have an almost infinite capacity for taking things for granted." - Aldous Huxley
    • Post Points: 35
  • 07-20-2007 3:18 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Indexed Properties And Custom Stored Procedures

    Sounds interesting. Can you post your code?

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 07-23-2007 4:25 AM In reply to

    • MrBretticus
    • Top 75 Contributor
    • Joined on 02-10-2006
    • Perth, Australia
    • Posts 54
    • Points 1,360

    Re: Indexed Properties And Custom Stored Procedures

    swin:

    Sounds interesting. Can you post your code?

    swin 

    I should clarify, when I say I've done some testing it was just purely test code, no .netTiers involvement. However attached is the code I used.

    Cheers, Brett "Most human beings have an almost infinite capacity for taking things for granted." - Aldous Huxley
    • Post Points: 5
  • 08-01-2007 2:49 AM In reply to

    • MrBretticus
    • Top 75 Contributor
    • Joined on 02-10-2006
    • Perth, Australia
    • Posts 54
    • Points 1,360

    Re: Indexed Properties And Custom Stored Procedures

    I just thought I'd share (roughly) what I would expect in .netTiers generated code if this was implemented:

    CREATE TABLE [Test] {
        [TestID] int IDENTITY(1,1) NOT NULL,
        [TestName] varchar(50) NOT NULL
    }

    CREATE PROCEDURE _Test_GetCustom
    AS
    BEGIN
        SELECT [TestID], [TestName], GETDATE() AS [QueriedDate] FROM [Test]
    END

    public abstract partial class Test
    {
        ...

        public Dictionary<string, object> Properties {
            get { return this.entityData.Properties; }
        }
       
        public virtual System.Int32 TestID {
            get { return this.entityData.TestID; }
            set {
                this.entityData.TestID = value;
                this.entityData.Properties["TestID"] = value;
            }
        }
       
        internal protected class TestEntityData
        {
            public Dictionary<string, object> Properties = new Dictionary<string, object>();

            ...
        }

        ...
    }

    public abstract partial class TestProviderBaseCore
    {
        ...

        public static Example.BusinessLogic.TList<Test> Fill(IDataReader reader, Example.BusinessLogic.TList<Test> rows, int start, int pageLength) {
            ...

            c.TestID = (System.Int32)reader["TestID"];
            c.TestName = (System.String)reader["TestName"];
            c.Properties["QueriedDate"] = (System.DateTime)reader["QueriedDate"];

            ...
        }

        ...
    }

    Cheers, Brett "Most human beings have an almost infinite capacity for taking things for granted." - Aldous Huxley
    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems