ExtensionDataObject showing up in service reference - c#

I'm writing a WCF service and the ExtensionDataObject shows up in my Reference.cs file of the service reference even though I don't have it defined in my data class.
I know what the ExtensionDataObject is for, but do not want to use it.
I don't know why it's showing up... Can somebody tell me how to not include it in my service reference? Additionally, there is an OptionalFieldAttribute which is declared in my service reference which again is not part of my data class. How can I remove this as well?
Here is the generated service reference declaration on my client:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="User", Namespace="http://www.Ryder.com/SOA/DataContracts/2014/02/17")]
[System.SerializableAttribute()]
public partial class User : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
[System.NonSerializedAttribute()]
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string PasswordField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private Ryder.ShopProcessService.Outbound.ShopProcessService.Permissions PermissionsField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string UserIDField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private Ryder.ShopProcessService.Outbound.ShopProcessService.UserTypeEnum UserTypeField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
get {
return this.extensionDataField;
}
set {
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string Password {
get {
return this.PasswordField;
}
set {
if ((object.ReferenceEquals(this.PasswordField, value) != true)) {
this.PasswordField = value;
this.RaisePropertyChanged("Password");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public Ryder.ShopProcessService.Outbound.ShopProcessService.Permissions Permissions {
get {
return this.PermissionsField;
}
set {
if ((object.ReferenceEquals(this.PermissionsField, value) != true)) {
this.PermissionsField = value;
this.RaisePropertyChanged("Permissions");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string UserID {
get {
return this.UserIDField;
}
set {
if ((object.ReferenceEquals(this.UserIDField, value) != true)) {
this.UserIDField = value;
this.RaisePropertyChanged("UserID");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public Ryder.ShopProcessService.Outbound.ShopProcessService.UserTypeEnum UserType {
get {
return this.UserTypeField;
}
set {
if ((this.UserTypeField.Equals(value) != true)) {
this.UserTypeField = value;
this.RaisePropertyChanged("UserType");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
Here is the corresponding class declaration in my service project: Note that I just changed the namespace to "abc" for privacy...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace abc.Enterprise.DataTransferObjects
{
[Serializable, DataContract(Name = "User", Namespace = "http://www.abc.com/SOA/DataContracts/2014/02/17")]
public class User
{
private UserTypeEnum userType;
private string userID;
private string password;
private Permissions permissions;
public User()
{
}
[DataMember(Name = "UserType")]
public UserTypeEnum UserType
{
get
{
return userType;
}
set
{
userType = value;
}
}
[DataMember(Name = "UserID")]
public string UserID
{
get
{
return userID;
}
set
{
userID = value;
}
}
[DataMember(Name = "Password")]
public string Password
{
get
{
return password;
}
set
{
password = value;
}
}
[DataMember(Name = "Permissions")]
public Permissions Permissions
{
get
{
return permissions;
}
set
{
permissions = value;
}
}
}
}

Related

Windows 8 Message Box Style WPF

I'm tryin to create WIN8 Msgbox Style in WPF and follow this
tuts. The problem is the message box called from the Main window.
Could you please help me if I want the message box appears when I press a button
from the child window ?
This is ViewModel of my Main Window
using FirstFloor.ModernUI.Presentation;
using dLondre;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dLondre.Models;
using dLondre.ViewModels;
using System.Windows;
using Caliburn.Micro;
using dLondre.Interfaces;
namespace dLondre.ViewModels
{
[Export(typeof(IShell))]
public class MainWindowViewModel : Screen, IShell
{
private readonly IWindowManager _windowManager;
private int _overlayDependencies;
[ImportingConstructor]
public MainWindowViewModel(IWindowManager windowManager)
{
_windowManager = windowManager;
}
public bool IsOverlayVisible
{
get { return _overlayDependencies > 0; }
}
public void ShowOverlay()
{
_overlayDependencies++;
NotifyOfPropertyChange(() => IsOverlayVisible);
}
public void HideOverlay()
{
_overlayDependencies--;
NotifyOfPropertyChange(() => IsOverlayVisible);
}
// I want to do this in the child window
// |
// |
// v
public void DisplayMessageBox()
{
MessageBoxResult dix;
dix = _windowManager.ShowMetroMessageBox("message", "title", MessageBoxButton.OKCancel);
if (dix == MessageBoxResult.OK)
{
_windowManager.ShowMetroMessageBox("OK");
}
else
{
_windowManager.ShowMetroMessageBox("CANCEL");
}
}
}
}
This is ViewModels of my Child Window
using FirstFloor.ModernUI.Presentation;
using dLondre;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using dLondre.Models;
using dLondre.ViewModels;
using System.Windows;
using Caliburn.Micro;
namespace dLondre.ViewModels {
public class UserViewModel : NotifyPropertyChanged, IDataErrorInfo
{
#region Construction
public UserViewModel()
{
_user = new User { FirstName = "",
LastName="",
Gender = "",
BirthDate= DateTime.Today,
Address="",
City="",
ZipCode="",
Email="",
UserID="",
Password="",
Status="",
Deleted=false,
CreatedOn=DateTime.Today,
CreatedBy="",
UpdatedOn=DateTime.Today,
UpdatedBy="" };
}
#endregion
#region Members
User _user;
#endregion
#region Properties
public User User
{
get
{
return _user;
}
set
{
_user = value;
}
}
public string FirstName
{
get { return User.FirstName; }
set
{
if (User.FirstName != value)
{
User.FirstName = value;
OnPropertyChanged("FirstName");
}
}
}
public string LastName
{
get { return User.LastName; }
set
{
if (User.LastName != value)
{
User.LastName = value;
OnPropertyChanged("LastName");
}
}
}
public string Gender
{
get { return User.Gender; }
set
{
if (User.Gender != value)
{
User.Gender = value;
OnPropertyChanged("Gender");
}
}
}
public DateTime BirthDate
{
get { return User.BirthDate; }
set
{
if (User.BirthDate != value)
{
User.BirthDate = value;
OnPropertyChanged("BirthDate");
}
}
}
public string Address
{
get { return User.Address; }
set
{
if (User.Address != value)
{
User.Address = value;
OnPropertyChanged("Address");
}
}
}
public string City
{
get { return User.City; }
set
{
if (User.City != value)
{
User.City = value;
OnPropertyChanged("City");
}
}
}
public string ZipCode
{
get { return User.ZipCode; }
set
{
if (User.ZipCode != value)
{
User.ZipCode = value;
OnPropertyChanged("ZipCode");
}
}
}
public string Email
{
get { return User.Email; }
set
{
if (User.Email != value)
{
User.Email = value;
OnPropertyChanged("Email");
}
}
}
public string UserId
{
get { return User.UserID; }
set
{
if (User.UserID != value)
{
User.UserID = value;
OnPropertyChanged("UserId");
}
}
}
public string Password
{
get { return User.Password; }
set
{
if (User.Password != value)
{
User.Password = value;
OnPropertyChanged("Password");
}
}
}
public string Status
{
get { return User.Status; }
set
{
if (User.Status != value)
{
User.Status = value;
OnPropertyChanged("Status");
}
}
}
public bool Deleted
{
get { return User.Deleted; }
set
{
if (User.Deleted != value)
{
User.Deleted = value;
OnPropertyChanged("Deleted");
}
}
}
public DateTime CreatedOn
{
get { return User.CreatedOn; }
set
{
if (User.CreatedOn != value)
{
User.CreatedOn = value;
OnPropertyChanged("CreatedOn");
}
}
}
public string CreatedBy
{
get { return User.CreatedBy; }
set
{
if (User.CreatedBy != value)
{
User.CreatedBy = value;
OnPropertyChanged("CreatedBy");
}
}
}
public DateTime UpdatedOn
{
get { return User.UpdatedOn; }
set
{
if (User.UpdatedOn != value)
{
User.UpdatedOn = value;
OnPropertyChanged("CreatedOn");
}
}
}
public string UpdatedBy
{
get { return User.UpdatedBy; }
set
{
if (User.UpdatedBy != value)
{
User.UpdatedBy = value;
OnPropertyChanged("UpdatedBy");
}
}
}
#endregion
public string Error
{
get { return null; }
}
public string this[string columnName]
{
get
{
if (columnName == "FirstName")
{
return string.IsNullOrEmpty(User.FirstName) ? "Required value" : null;
}
if (columnName == "LastName")
{
return string.IsNullOrEmpty(User.LastName) ? "Required value" : null;
}
if (columnName == "Email")
{
return string.IsNullOrEmpty(User.Email) ? "Required value" : null;
}
if (columnName == "UserId")
{
return string.IsNullOrEmpty(User.UserID) ? "Required value" : null;
}
return null;
}
}
private readonly IWindowManager _windowManager;
// Here comes the trouble
// |
// |
// v
public void DisplayMessageBox()
{
_windowManager.ShowMetroMessageBox("Are you sure you want to delete...", "Confirm Delete",
MessageBoxButton.YesNo);
}
}
}
This is my sampleproject
Surely if you copy the following code into your child view model then you can call it from there?
private readonly IWindowManager _windowManager;
public void DisplayMessageBox()
{
_windowManager.ShowMetroMessageBox("Are you sure you want to delete...", "Confirm
Delete", MessageBoxButton.YesNo);
}

Add service reference generated my client incompelety

Something has gone wrong when I "Add Service Reference" to target my wcf.
I target my wcf and clicked OK. You get after OK normally a nice generated files like Reference.cs (client). I see know that Reference.cs is incompeletely generated. See below:
namespace WindowsPhoneApp.ServiceReference1 {
using System.Runtime.Serialization;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="AlgemeenKlassementJSON", Namespace="http://schemas.datacontract.org/2004/07/WcfOpzet.jsonModels")]
public partial class AlgemeenKlassementJSON : object, System.ComponentModel.INotifyPropertyChanged {
private long idField;
private long puntenField;
private string rennersField;
private long rondesField;
private long teamnrField;
[System.Runtime.Serialization.DataMemberAttribute()]
public long id {
get {
return this.idField;
}
set {
if ((this.idField.Equals(value) != true)) {
this.idField = value;
this.RaisePropertyChanged("id");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public long punten {
get {
return this.puntenField;
}
set {
if ((this.puntenField.Equals(value) != true)) {
this.puntenField = value;
this.RaisePropertyChanged("punten");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string renners {
get {
return this.rennersField;
}
set {
if ((object.ReferenceEquals(this.rennersField, value) != true)) {
this.rennersField = value;
this.RaisePropertyChanged("renners");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public long rondes {
get {
return this.rondesField;
}
set {
if ((this.rondesField.Equals(value) != true)) {
this.rondesField = value;
this.RaisePropertyChanged("rondes");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public long teamnr {
get {
return this.teamnrField;
}
set {
if ((this.teamnrField.Equals(value) != true)) {
this.teamnrField = value;
this.RaisePropertyChanged("teamnr");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="TeamsJSON", Namespace="http://schemas.datacontract.org/2004/07/WcfOpzet.jsonModels")]
public partial class TeamsJSON : object, System.ComponentModel.INotifyPropertyChanged {
private WindowsPhoneApp.ServiceReference1.Image fotorennerAField;
private byte[] fotorennerBField;
private long idField;
private byte[] landrennerAField;
private byte[] landrennerBField;
private string rennerAField;
private string rennerBField;
private string teamNaamField;
private byte[] teamShirtField;
[System.Runtime.Serialization.DataMemberAttribute()]
public WindowsPhoneApp.ServiceReference1.Image fotorennerA {
get {
return this.fotorennerAField;
}
set {
if ((object.ReferenceEquals(this.fotorennerAField, value) != true)) {
this.fotorennerAField = value;
this.RaisePropertyChanged("fotorennerA");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public byte[] fotorennerB {
get {
return this.fotorennerBField;
}
set {
if ((object.ReferenceEquals(this.fotorennerBField, value) != true)) {
this.fotorennerBField = value;
this.RaisePropertyChanged("fotorennerB");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public long id {
get {
return this.idField;
}
set {
if ((this.idField.Equals(value) != true)) {
this.idField = value;
this.RaisePropertyChanged("id");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public byte[] landrennerA {
get {
return this.landrennerAField;
}
set {
if ((object.ReferenceEquals(this.landrennerAField, value) != true)) {
this.landrennerAField = value;
this.RaisePropertyChanged("landrennerA");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public byte[] landrennerB {
get {
return this.landrennerBField;
}
set {
if ((object.ReferenceEquals(this.landrennerBField, value) != true)) {
this.landrennerBField = value;
this.RaisePropertyChanged("landrennerB");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string rennerA {
get {
return this.rennerAField;
}
set {
if ((object.ReferenceEquals(this.rennerAField, value) != true)) {
this.rennerAField = value;
this.RaisePropertyChanged("rennerA");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string rennerB {
get {
return this.rennerBField;
}
set {
if ((object.ReferenceEquals(this.rennerBField, value) != true)) {
this.rennerBField = value;
this.RaisePropertyChanged("rennerB");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string teamNaam {
get {
return this.teamNaamField;
}
set {
if ((object.ReferenceEquals(this.teamNaamField, value) != true)) {
this.teamNaamField = value;
this.RaisePropertyChanged("teamNaam");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public byte[] teamShirt {
get {
return this.teamShirtField;
}
set {
if ((object.ReferenceEquals(this.teamShirtField, value) != true)) {
this.teamShirtField = value;
this.RaisePropertyChanged("teamShirt");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
public class Image {
**Incomplete!**
}
**Incomplete! I miss my operations of my wcf**
}
Here an image where my problem is started. (Need at least 10 rept points, no images :D)
Don't use non-seriazable types that the datacontractserializer can't handle such as System.drawing.

How to use MVVM Light With Sql Server Compact - Windows Phone 7?

I am using MVVM Light, Sql Server Compact Toolkit and windows phone 7.
I created a sql server compact 3.5 database and then used the toolkit to generate the datacontext and domain class for each table.
Looks like this
[global::System.Data.Linq.Mapping.TableAttribute(Name = "ContactGroups")]
public partial class ContactGroup : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _Id;
private string _Title;
private System.DateTime _LastUpdated;
private EntitySet<GContact> _GContacts;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnIdChanging(int value);
partial void OnIdChanged();
partial void OnTitleChanging(string value);
partial void OnTitleChanged();
partial void OnLastUpdatedChanging(System.DateTime value);
partial void OnLastUpdatedChanged();
#endregion
public ContactGroup()
{
this._GContacts = new EntitySet<GContact>(new Action<GContact>(this.attach_GContacts), new Action<GContact>(this.detach_GContacts));
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Id", DbType = "Int NOT NULL", IsPrimaryKey = true)]
public int Id
{
get
{
return this._Id;
}
set
{
if ((this._Id != value))
{
this.OnIdChanging(value);
this.SendPropertyChanging();
this._Id = value;
this.SendPropertyChanged("Id");
this.OnIdChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Title", DbType = "NVarChar(100) NOT NULL", CanBeNull = false)]
public string Title
{
get
{
return this._Title;
}
set
{
if ((this._Title != value))
{
this.OnTitleChanging(value);
this.SendPropertyChanging();
this._Title = value;
this.SendPropertyChanged("Title");
this.OnTitleChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_LastUpdated", DbType = "DateTime NOT NULL")]
public System.DateTime LastUpdated
{
get
{
return this._LastUpdated;
}
set
{
if ((this._LastUpdated != value))
{
this.OnLastUpdatedChanging(value);
this.SendPropertyChanging();
this._LastUpdated = value;
this.SendPropertyChanged("LastUpdated");
this.OnLastUpdatedChanged();
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name = "FK_GContacts_ContactGroups", Storage = "_GContacts", ThisKey = "Id", OtherKey = "ContactGroups_Id", DeleteRule = "NO ACTION")]
public EntitySet<GContact> GContacts
{
get
{
return this._GContacts;
}
set
{
this._GContacts.Assign(value);
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private void attach_GContacts(GContact entity)
{
this.SendPropertyChanging();
entity.ContactGroup = this;
}
private void detach_GContacts(GContact entity)
{
this.SendPropertyChanging();
entity.ContactGroup = null;
}
}
Yet when I try to make it blendable(ie make fake data so when I go into blend I can work with it better instead of looking at empty boxes) nothing shows up in blend
when I have a simple domain without it works
public class ContactGroup
{
public int Id { get; set; }
public string Title { get; set; }
public DateTime LastUpdated { get; set; }
public List<GContacts> Contacts { get; set; }
public ContactGroup()
{
Contacts = new List<GContacts>();
}
}
Then in my viewmodel locator I would have
if (ViewModelBase.IsInDesignModeStatic)
{
SimpleIoc.Default.Register<IContactService, DesignContactService>();
}
else
{
SimpleIoc.Default.Register<IContactService, DesignContactService>();
}
Edit
The problem line seens to be this
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
When I remove it then blend shows the data again.

ObjectDataSource connection

I'm trying to work through Pluralsights ASP.NET Webforms (c#) demos and cannot figure out why my class in my app_code folder will not show in my ObjectDataSource dropdown list when trying to create a new Datasource connection. I've been stuck on this for nearly a week and a half and am new to programming so don't understand all of the lingo after searching for helpful documents. I don't know where to implement what.
Here's the code for my BAL.cs class located in my App_Code Folder and I have a Data folder with a Linq to class connection named Northwind.
// Here is my code for BAL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using Northwind;
public class BAL
{
public List<String> GetCountries()
{
using (var context = new NorthwindDataContext())
{
return (from c in context.Customers
select c.Country).Distinct().ToList();
}
}
public List<Customer> GetCustomersByCountry(string country)
{
using (var context = new NorthwindDataContext())
{
return (from c in context.Customers
where c.Country == country
select c).ToList();
}
}
public Customer GetCustomer(string custID)
{
using (var context = new NorthwindDataContext())
{
return (from c in context.Customers
where c.CustomerID == custID
select c).SingleOrDefault();
}
}
}
}
Now the designer.cs for my Northwind.dbml file
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Northwind
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Northwind")]
public partial class NorthwindDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new
AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void InsertCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
partial void DeleteCustomer(Customer instance);
#endregion
public NorthwindDataContext() :
base
(global::System.Configuration.ConfigurationManager.ConnectionStrings
["NorthwindConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
public NorthwindDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public NorthwindDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public NorthwindDataContext(string connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public NorthwindDataContext(System.Data.IDbConnection connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<Customer> Customers
{
get
{
return this.GetTable<Customer>();
}
}
}
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Customers")]
public partial class Customer : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new
PropertyChangingEventArgs(String.Empty);
private string _CustomerID;
private string _CompanyName;
private string _ContactName;
private string _ContactTitle;
private string _Address;
private string _City;
private string _Region;
private string _PostalCode;
private string _Country;
private string _Phone;
private string _Fax;
private string _Image;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnCustomerIDChanging(string value);
partial void OnCustomerIDChanged();
partial void OnCompanyNameChanging(string value);
partial void OnCompanyNameChanged();
partial void OnContactNameChanging(string value);
partial void OnContactNameChanged();
partial void OnContactTitleChanging(string value);
partial void OnContactTitleChanged();
partial void OnAddressChanging(string value);
partial void OnAddressChanged();
partial void OnCityChanging(string value);
partial void OnCityChanged();
partial void OnRegionChanging(string value);
partial void OnRegionChanged();
partial void OnPostalCodeChanging(string value);
partial void OnPostalCodeChanged();
partial void OnCountryChanging(string value);
partial void OnCountryChanged();
partial void OnPhoneChanging(string value);
partial void OnPhoneChanged();
partial void OnFaxChanging(string value);
partial void OnFaxChanged();
partial void OnImageChanging(string value);
partial void OnImageChanged();
#endregion
public Customer()
{
OnCreated();
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CustomerID",
DbType="NChar(5) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
public string CustomerID
{
get
{
return this._CustomerID;
}
set
{
if ((this._CustomerID != value))
{
this.OnCustomerIDChanging(value);
this.SendPropertyChanging();
this._CustomerID = value;
this.SendPropertyChanged("CustomerID");
this.OnCustomerIDChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CompanyName",
DbType="NVarChar(40) NOT NULL", CanBeNull=false)]
public string CompanyName
{
get
{
return this._CompanyName;
}
set
{
if ((this._CompanyName != value))
{
this.OnCompanyNameChanging(value);
this.SendPropertyChanging();
this._CompanyName = value;
this.SendPropertyChanged("CompanyName");
this.OnCompanyNameChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ContactName",
DbType="NVarChar(30)")]
public string ContactName
{
get
{
return this._ContactName;
}
set
{
if ((this._ContactName != value))
{
this.OnContactNameChanging(value);
this.SendPropertyChanging();
this._ContactName = value;
this.SendPropertyChanged("ContactName");
this.OnContactNameChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ContactTitle",
DbType="NVarChar(30)")]
public string ContactTitle
{
get
{
return this._ContactTitle;
}
set
{
if ((this._ContactTitle != value))
{
this.OnContactTitleChanging(value);
this.SendPropertyChanging();
this._ContactTitle = value;
this.SendPropertyChanged("ContactTitle");
this.OnContactTitleChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Address",
DbType="NVarChar(60)")]
public string Address
{
get
{
return this._Address;
}
set
{
if ((this._Address != value))
{
this.OnAddressChanging(value);
this.SendPropertyChanging();
this._Address = value;
this.SendPropertyChanged("Address");
this.OnAddressChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_City",
DbType="NVarChar(15)")]
public string City
{
get
{
return this._City;
}
set
{
if ((this._City != value))
{
this.OnCityChanging(value);
this.SendPropertyChanging();
this._City = value;
this.SendPropertyChanged("City");
this.OnCityChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Region",
DbType="NVarChar(15)")]
public string Region
{
get
{
return this._Region;
}
set
{
if ((this._Region != value))
{
this.OnRegionChanging(value);
this.SendPropertyChanging();
this._Region = value;
this.SendPropertyChanged("Region");
this.OnRegionChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PostalCode",
DbType="NVarChar(10)")]
public string PostalCode
{
get
{
return this._PostalCode;
}
set
{
if ((this._PostalCode != value))
{
this.OnPostalCodeChanging(value);
this.SendPropertyChanging();
this._PostalCode = value;
this.SendPropertyChanged("PostalCode");
this.OnPostalCodeChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Country",
DbType="NVarChar(15)")]
public string Country
{
get
{
return this._Country;
}
set
{
if ((this._Country != value))
{
this.OnCountryChanging(value);
this.SendPropertyChanging();
this._Country = value;
this.SendPropertyChanged("Country");
this.OnCountryChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Phone",
DbType="NVarChar(24)")]
public string Phone
{
get
{
return this._Phone;
}
set
{
if ((this._Phone != value))
{
this.OnPhoneChanging(value);
this.SendPropertyChanging();
this._Phone = value;
this.SendPropertyChanged("Phone");
this.OnPhoneChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Fax",
DbType="NVarChar(24)")]
public string Fax
{
get
{
return this._Fax;
}
set
{
if ((this._Fax != value))
{
this.OnFaxChanging(value);
this.SendPropertyChanging();
this._Fax = value;
this.SendPropertyChanged("Fax");
this.OnFaxChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Image",
DbType="NVarChar(50)")]
public string Image
{
get
{
return this._Image;
}
set
{
if ((this._Image != value))
{
this.OnImageChanging(value);
this.SendPropertyChanging();
this._Image = value;
this.SendPropertyChanged("Image");
this.OnImageChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new
PropertyChangedEventArgs (propertyName));
}
}
}
}
#pragma warning restore 1591
If they're not showing up in the GUI, try manually specifying which methods go with which actions.
Eg:
[DataObjectMethod(DataObjectMethodType.Select, true)]
[DataObjectMethod(DataObjectMethodType.Insert, true)]
[DataObjectMethod(DataObjectMethodType.Update, true)]
[DataObjectMethod(DataObjectMethodType.Delete, true)]
More info here.
You need to make sure your project type is a Web project, otherwise Visual Studio will not consider the App_Code folder
Make sure you include System.Data.Linq as a reference in your Web.Config file bz adding the following
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
Following is the Web.Config file content. I got the content from the exercise files on the Introduction to ASP.NET 4 WebForms course from pluralsight:
See comments here: stackoverflow.com/questions/16170156/
I think adding an assembly ref to web.config solved the problem for me.

Display right datamember in the datagridview by using Bindinglist

Goal:
Display Encapsulate field from Player
Problem:
Want to display datamember_id, _name and _bust in class mainform only by using bindingList
Was it suppose to use syntax [] above the encapsulate field?
Class MainForm
dataGridViewPlayers.AutoGenerateColumns=true;
dataGridViewPlayers.AutoSizeColumnsMode=DataGridViewAutoSizeColumnsMode.Fill;
bindingSourcePlayers.Clear();
bindingSourcePlayers.DataSource = _myGameManager.Players;
Class GameManager:
public BindingList<Player> Players
{
get
{
for (int i = 0; i < _myPlayerGUI_list.Count; i++)
{
_player.Add(new Player(_myPlayerGUI_list[i].Player));
}
return _player;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CardGameClassLibrary;
namespace CardGameLib
{
public class Player
{
private int _id;
private string _name;
private Hand _myHand;
private int _win;
private int _lost;
private bool _madeMove = false;
private bool _bust = false;
public int Id
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public Hand MyHand
{
get { return _myHand; }
set { _myHand = value; }
}
public int Win
{
get { return _win; }
set { _win = value; }
}
public int Lost
{
get { return _lost; }
set { _lost = value; }
}
public bool MadeMove
{
get { return _madeMove; }
set { _madeMove = value; }
}
public bool Bust
{
get { return _bust; }
set { _bust = value; }
}
public Player(int pId)
{
_id = pId;
_myHand = new Hand();
}
public Player(Player pPlayer)
{
_id = pPlayer.Id;
//_name = pPlayer.Name;
_name = "adsf";
}
public Player()
{
}
}
}
You can use Browsable() attribute to prevent specific properties from being shown in the DataGridView when usin BindingList.
Example: if you want to hide MadeMove:
[Browsable(false)]
public bool MadeMove
{
get { return _madeMove; }
set { _madeMove = value; }
}

Categories