CodeSmith Community
Your Code. Your Way. Faster!

table named 'Events'

Latest post 05-15-2008 4:17 PM by SuperJeffe. 3 replies.
  • 05-15-2008 1:26 PM

    • dsiddell
    • Top 500 Contributor
    • Joined on 04-30-2008
    • Posts 9
    • Points 280

    table named 'Events'

    I am getting some strange behavior around the entities for my table named 'Events'. 

    For example this code repeatedly (but not every time) gets null references on the two container entities GroupIdSource and VenueIdSource:

    <table align="center" class="txt">

    <data:EventsRepeater ID="RepeaterEvents" DataSourceID="EventsDataSource" runat="server">

    <ItemTemplate>

    <tr>

    <td><b><%# String.Format("{0:f}", Container.DateAndTime)%> - </b></td>

    <td><b><%# Container.Entity.GroupIdSource.Description %> - </b></td>

    <td><b><%# Container.Entity.VenueIdSource.Description %></b></td>

    </tr>

    <tr>

    <td colspan="3"><b><%# String.Format("${0:N0}", Container.Price)%></b></td>

    </tr>

    <tr><td colspan="3"><hr width="100%"></td></tr>

    </ItemTemplate>

    </data:EventsRepeater>

    </table>

     

    <data:EventsDataSource ID="EventsDataSource" runat="server"

    SelectMethod="GetByEventId"

    >

    <Parameters>

    <asp:QueryStringParameter Name="EventId" QueryStringField="EventId" Type="String" />

    </Parameters>

    </data:EventsDataSource>

     

    Then this code:

    string qsEventID;
    qsEventID = Request.QueryString["EventId"].ToString();

    DateTime eventDate;
    EventsParameterBuilder query1 = new EventsParameterBuilder();
    query1.Append(
    EventsColumn.EventId, qsEventID);

    TList<Events> list1 = DataRepository.EventsProvider.Find(query1.GetParameters());
    if (list1.Count > 0)
    {
    eventDate = list1[0].DateAndTime;
    }

    throws this error:

    Error 22 The type 'Events' must be convertible to 'Sitename.Entities.IEntity' in order to use it as parameter 'T' in the generic type or method 'Sitename.Entities.TList<T>'

     

    Am I doing something wrong or is the name 'Events' having keyword issues?

    Thanks for your help,

    Don

    • Post Points: 35
  • 05-15-2008 2:51 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 408
    • Points 10,260

    Re: table named 'Events'

    The Null reference exception means you may not have Deep Loaded the entity.  The xxxSource properties are only populated during a deepload.

    Events is probably a keyword.  Just put the full Namespace in there to see if that fixes:

    TList<xx.xx.Events>

    jeff

     

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 35
  • 05-15-2008 3:05 PM In reply to

    • dsiddell
    • Top 500 Contributor
    • Joined on 04-30-2008
    • Posts 9
    • Points 280

    Re: table named 'Events'

    Adding the full namespace worked, so does that mean I should expect "keyword" issues from generated code or does the gen'd code always fully qualify?  Meaning should I not risk it and use an alias for my tables (mapping file)?

    The other block does work 75% of the time but gets that null reference the other 25%.  This is what I am worried about in terms of maybe needing to use an alias.

    I had this code in there as well but it didn't help:

    <DeepLoadProperties Method="IncludeChildren" Recursive="False">

    <Types>

    <data:EventsProperty Name="Venues"/>

    <data:EventsProperty Name="Groups"/>

    <%--<data:EventsProperty Name="MemberEventsCollection" />--%>

    <%--<data:EventsProperty Name="MembersCollection_From_MemberEvents" />--%>

    </Types>

    </DeepLoadProperties>

    If that's what you meant then that did not resolve the issue.

    It's not a big site but I don't want to be chasing down "keyword" issues either.

    Thanks again Jeff!  (you'll probably be glad when I've finished this project)

    • Post Points: 35
  • 05-15-2008 4:17 PM In reply to

    • SuperJeffe
    • Top 25 Contributor
    • Joined on 05-05-2006
    • Tulsa, Ok
    • Posts 408
    • Points 10,260

    Re: table named 'Events'

    If I had that table, I would probably alias it.  The generated code I believe is fully qualified.

    That seems to be a little weird to get it some of the times and not.  What I would do is try to capture the Binding Event in code behind and see if you can see what the DataObject looks like.  See if it is null or not.  That would just be the place I would start to debug it.  I don't use the DataSources that are generated from Nettiers so I might not be the biggest help when it comes to tracking this down.  I would start with that Event though.

    jeff

    ----------------------------------------------------------------------
     Member of the .NetTiers team | Visit http://www.nettiers.com
    ----------------------------------------------------------------------

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems