c# - PropertyGroupDescription not working as expected -


i using linq sql in c# wpf application , trying use propertygroupdescription group listview lastnames sql server db.

my db linq designer mapping column looks this:

[global::system.data.linq.mapping.columnattribute(storage="_lastname", autosync=autosync.always, dbtype="varchar(max)", isdbgenerated=true, updatecheck=updatecheck.never)]         public string lastname         {                         {                 return this._lastname;             }             set             {                 if ((this._lastname != value))                 {                     this.onlastnamechanging(value);                     this.sendpropertychanging();                     this._lastname = value;                     this.sendpropertychanged("lastname");                     this.onlastnamechanged();                 }             }         } 

the table name in db contacts, thought linq code table bit post gave name.

i have observable collection of db table binding itemsource of listview to.

public observablecollection<namespace.database.contact> contacts         {             get;             set;         } 

here how trying , failing while using propertygroupdescription

    collectionview view = (collectionview)collectionviewsource.getdefaultview(this.contacts);     propertygroupdescription groupdescription = new propertygroupdescription(this.contacts.lastname);  //<-- cant     view.groupdescriptions.add(groupdescription); 

since there can same last name multiple time, want group it.

i assuming above, cannot:

i have tried:

this.contacts.where(x => x.lastname!= null).tostring().firstordefault());  this.contacts.select(x => x.lastname!= null).tostring() 

what doing wrong?

thanks or replies.

use

collectionview view = (collectionview)collectionviewsource.getdefaultview(this.contacts); propertygroupdescription groupdescription = new propertygroupdescription("lastname");   view.groupdescriptions.add(groupdescription); 

instead.

you should use hardcoded property name in propertygroupdescription's constructor.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -