in

CodeSmith Community

Your Code. Your Way. Faster!

Please Help with getting started from Wiki

Last post 11-02-2006 10:01 AM by swin. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 11-02-2006 1:40 AM

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Please Help with getting started from Wiki

    Hi all, having some trouble so I read over Wiki again and started from the "Getting Started" page: http://wiki.nettiers.com/gettingstarted2

    I have generated from Northwind to keep things simple:

    • Northwind.Data
    • Northwind.Data.SqlClient
    • Northwind.Entities
    • Northwind.Services
    • Northwind.Web
    • Northwind.WebSite

    This is what I have done so far:

        1 #region Using Directives

        2 

        3 using System;

        4 using System.Web.UI;

        5 using Northwind.Entities;

        6 using Northwind.Services;

        7 

        8 #endregion

        9 

       10 namespace Northwind.Website

       11 {

       12     public partial class _Default : Page

       13     {

       14 

       15         private ProductsService productService;

       16         protected ProductsService ProductService

       17         {

       18             get

       19             {

       20                 if (productService == null)

       21                 {

       22                     productService = new ProductsService();

       23                 }

       24                 return productService;

       25             }

       26         }

       27         protected void Page_Load(object sender, EventArgs e)

       28         {

       29 

       30             //GridView1.DataSource = ProductService.GetAll(); OK

       31 

       32             //GridView1.DataSource = ProductService.GetByCategoryID(1); OK

       33 

       34             //GridView1.DataSource = ProductService.GetByProductID(1);

       35             //Error Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.

       36 

       37             GridView1.DataBind();

       38         }

       39 

       40         protected void test()

       41         {

       42             //GetAll()

       43             TList<Products> productsList = ProductService.GetAll();

       44         }

       45     }

       46 }

     

    Firstly, using the Services Layer I can bind with some methods but not all. All the FK methods are ok as well as by any index that is created. However I get error on PK, as above. I havn't got through all methods yet such as DeepLoad but that's ok I'll get to that when I can get basic stuff working.


    I then continued the Wiki Getting Started with TList<T> and get intelliSense error on first one above.

    "The type 'Products' must be convertible to 'Nothwind.Entities.IEntity' in order to use it as a parameter 'T' in the generic class 'Northwind.Entities.TList<T>'

     

    Please, please, please can someone point me in the right direction as I think NetTiers is a great idea and would like to use it. In the past I have usually written evrything by hand although I usually only write two tier projects but would like to advance my skills and knowledge. I'm sure once I can get over this initial bump it will be fun to program against.

     

    Thanks in advance

    Axe

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 2:12 AM In reply to

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

    Re: Please Help with getting started from Wiki

    The problem is that the GetByProductID is returning a single entity and as such is not enumerable.  The other 2 are returning collections of objects and so they are enumerable.

    You might also like to have a look at the strongly typed data sources and EntityDataSource (make sure you generate the Web library) as these make setting up a GridView and dropdownlist's a piece of cake.

    HTH

    swin

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 60
  • 11-02-2006 3:31 AM In reply to

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Re: Please Help with getting started from Wiki

    Thanks for the speedy response :)

    I have looked at the typed data sources and I guess I have a bit of resistance as I have, over the last 6 months, been playing with .net's strongly typed Datasets but have always found limitations and always need to go to code even if it's on the ObjectDataSources' events, on updating ect.. They work well on simple table schemas but my experience has always been that real projects are never that straight forward. So at work I keep coding everything by hand because I feel I have more control over what’s happening. I have built complete projects using Typed DataSets but, I don't know, it just feels clumsy sometimes. I found these templates and thought I could reduce alot of repetitive DAL coding and I'm still really looking for a good all round solution. NetTiers seems to fit this category just impatient as I want to get things going. NetTiers seems simple and logical but haven't quite got it yet. I know alot of people on these forums ask similar things and what would really make this take off is one fairly broad application in two versions. One using typed data source and one using all code. In the end I would use a mixture of both. Horses for Courses as they say.
    Now I feel I bit stuck not sure which way to go. I know LINQ is coming and all however I concerned a similar thing will happen as did with Types Datasets. I guess I'll have to wait to see how things pan out and in the meantime learn as much as I can. I can continue writing every thing by hand but I think with the evolution of Rapid Application Development if u don't jump on some boat u will just not be fast enough so u can't stay competitive.

    Thanks again
    If anyone has any more advice, information or links please don't be shy. Or let us know your real world experience with NetTiers.

     

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 4:20 AM In reply to

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

    Re: Please Help with getting started from Wiki

    Of course NetTiers isn't going to be everything to everyone, but I feel its got a lot of good things going for it.

    The typed datasources are quick and easy way of moving data between the web ui and database.  Of course they don't do everting and so some hand coding is inevitable - but saying that you can get functional forms working with very little in the code behind - check out the admin screens for one.

    On the NetTiers website LINQ and .NET 3.0 are mentioned so I would envisage that they have plans to incorporate them in to the templates.

    Cheers

    swin

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 35
  • 11-02-2006 5:21 AM In reply to

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Re: Please Help with getting started from Wiki

    Don't get me wrong!
    I think NetTiers is great and can be a very solid development model and I'm not that naive to think that it can do it all. I prefer to code to start with and when I know the ins and outs then use design based methods. The current documentation is great for the 'What' maybe just a
    little more 'How’ is needed. It is there but I guess it presumes the user is at a certain level already. A sample application which covers most table relationships, which NetTiers build for you, would go a long way to understanding how to work with NetTiers is a fast and efficient manner.

     

    I have learnt a lot from the Wiki about the model and their various layers which has already increased my knowledge. Everyone learns differently and I tend to learn from the top down in most things in life. I will keep going with it as I don’t like to be defeated by perceived difficulty. I’m probably a bit rushed at the moment as well. It’s hard though to set aside time to learn something when I’m not using it on a real project. Maybe I have jumped the gun a bit by trying to use NetTiers for my current project which of course always needs finishing yesterday.

    Thanks for taking the time to read and respond.

     

    Axe

     

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 6:45 AM In reply to

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

    Re: Please Help with getting started from Wiki

    There is quite a bit to learn in NT and as its still moving it is hard to get to grips with sometimes. 

    There is a lot of info on the forums, but it is hard sometimes to get to the answer quickly - and of course a lot of people are under time constraints with their own developments. 

    I totally agree that we need some "How to" types guides.   Maybe there should be some effort to create these "How to" guides?? (with effort not just from the NT team) - I'd be willing to help with my (limited!) experienced gained in the last couple of months using NT.

    swin

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 5
  • 11-02-2006 6:53 AM In reply to

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Re: Please Help with getting started from Wiki

    ok

    I have dug a little deeper into the generated code. I am looking at the CustomersServiceBase.generated.cs. Looking at the various methods I see what you mean in your first post. The GetByCustomerID method returns a Northwind.Entities.Customers object but other methods such as GetByPostalCode returns TList<Customers> which is of course bindable. So any method that returns TList<T> I can bind with which is great. What I don't get yet is why are some methods returning Customers object and some a TList<T>. If I wanted GetByCustomerID as List<Customers>, should I add a method to the CustomersService.cs file? Or is there another way to work with single entities? Or have I just lost the plot and missing some simple obvious fact Stick out tongue

    I feel I'm getting closer. Wink
    I will continue looking into generated code to see if I can work this out.

    Thanks

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 7:19 AM In reply to

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

    Re: Please Help with getting started from Wiki

    It's down to the indexes and relationships on the tables.

    A unique constraint will give you a method that returns a single entity, a non-unique one will give you a method that returns a collection of entities

    When you have a foreign key relationship you also get a an xxxIDSource property in your entity - if you DeepLoad the entity then this property is populated with the referenced entity.

    HTH

    swin

     

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 35
  • 11-02-2006 8:14 AM In reply to

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Re: Please Help with getting started from Wiki

    So from my limited understanding so far using Northwind Customers, TList<Customers> is a collection of Northwind.Entities.Customers and esentially a Customer entity represents one row of data???

    How would I then fill a Customer Entity with one row of data?
    And could I then say something like string s = customer.field name?
    I have tried a few things but not had any success yet.

    Just trying to get to the bottom of selecting one row of data based on a unique contraint as you mentioned above.

    Thanks for all your help swin.

    btw is it getting cold in London now? We've had some pretty hot days lately and I think it's going to be a very hot summer here.

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 9:04 AM In reply to

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

    Re: Please Help with getting started from Wiki

    TList is a NetTiers enchanced "List" class which is .NET 2 Generics feature (it creates a strongly typed collection of the object type specified).

    To get one customer entity...

    Customers myCustomer = ProductService.GetByCategoryID(1);

    and once you have your entity you're free to use the properties such as name.

    or to get all customers

    TList<Customers> customerList = ProductService.GetAll();

    You should check out the documentation as they have more examples of this sort of thing (wiki.nettiers.com)

    and yes London is cold today!

    Cheers

    swin

     

    Axe:

    So from my limited understanding so far using Northwind Customers, TList<Customers> is a collection of Northwind.Entities.Customers and esentially a Customer entity represents one row of data???

    How would I then fill a Customer Entity with one row of data?
    And could I then say something like string s = customer.field name?
    I have tried a few things but not had any success yet.

    Just trying to get to the bottom of selecting one row of data based on a unique contraint as you mentioned above.

    Thanks for all your help swin.

    btw is it getting cold in London now? We've had some pretty hot days lately and I think it's going to be a very hot summer here.

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 35
  • 11-02-2006 9:49 AM In reply to

    • Axe
    • Top 500 Contributor
    • Joined on 10-17-2006
    • Sydney, AU
    • Posts 14
    • Points 460

    Re: Please Help with getting started from Wiki

    Thanks heaps. Big Smile

    I have been reading over the last hour or so and playing with examples. It is coming together for me now, I think!

    When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
    - Sherlock Holmes, as recorded by Sir A. C. Doyle in "The Blanched Soldier"
    • Post Points: 35
  • 11-02-2006 10:01 AM In reply to

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

    Re: Please Help with getting started from Wiki

    bonza!

    Big Smile

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 5
Page 1 of 1 (12 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems