none
Custom Readonly Properties in linq? RRS feed

  • Question

  •  

    Imagine we have a table of staff (id, firstname, secondname) and to display them in a dropdownlist we use a linq datasource. Now if I want to display their fullname in the dropdownlist I try creating a partial class with a readonly property fullname which returns firstname plus a space plus secondname, then tell the linqdatasource to select the id and the fullname and bind to the dropdownlist. This works if the data is coming from sql 2005 but throws a "fullname is not a property of etc..." error if it is data coming from sql 2000. Is this correct behaviour?

    Friday, March 28, 2008 7:37 PM

Answers

  • As there has been no activity or new information on this thread I'm going to mark it as closed but feel free to reopen the thread if you wish to continue the discussion.

     

    [)amien

    Tuesday, June 10, 2008 8:08 PM
    Moderator

All replies

  • Hi,

     

    I can't tell you anything about the problem with Sql Server 2000.

    I know it's running with Sql Server 2005 since I used this too. You can use it to build calculated fields like fullname or have unmapped fields like flags too. Everthing is fine as long as I used it in my code, but Visual Studio doesn't show user defined properties in the Data Sources window. I guess some components have problems with partial classes when they have to deal with the source code files.

     

    regards

    Philipp

    Friday, March 28, 2008 8:38 PM
  • Well I wouldnt expect to see it in the datasources window as that is exactly what it says on the tin, data sources. But put a linqdatasource on a webpage, configure it and select say the staff table in this case and you will see the FullName property. You will see this even if it is a Sql Server 2000 DB but then at runtime it will not work. I think it's a pity this kind of limitation is not documented if it is the case. For all the excellent linq tutorials and videos out there this is a case that is not covered but is quite common.

     

    Saturday, March 29, 2008 3:30 AM
  • I'm not familiar with asp.net programming, but it sounds great that you see this property when you configure the linqdatasource. In the forms designer you won't see it. Not only in Data Sources but it isn't shown if you want to databind some controls to it.

    Maybe they solve some of these issues in SP1. I read they are very busy working on SP1.

    Saturday, March 29, 2008 11:39 AM
  • Do you have a small sample app that demonstrates this issue so I can try it against 2000 and SP1?

     

    Regards,

     

    [)amien

     

    Wednesday, May 28, 2008 6:59 PM
    Moderator
  • As there has been no activity or new information on this thread I'm going to mark it as closed but feel free to reopen the thread if you wish to continue the discussion.

     

    [)amien

    Tuesday, June 10, 2008 8:08 PM
    Moderator