I am using sql server 2008, to follow the latest convention I used new schema other than [dbo].[tablename] which is now look like this [newdbo].[tablename]. The problem now, SimpleRepository could not locate [newdbo].[tablename], I assumed it is looking for [dbo] rather than [newdbo], since my class is define as:
here's my Table: Schema/owner is "kiss"
CREATE TABLE [kiss].[Users](
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](20) NOT NULL,
[UserPassword] [varbinary](128) NULL,
[UserTypeID] [tinyint] NOT NULL,
[ByPassAccessRestrictionsFlag] [bit] NOT NULL,
[IsEnforcePasswordPolicy] [bit] NOT NULL,
[PasswordExpirationDate] [datetime] NULL,
[IsPwdChangeNextLogin] [bit] NOT NULL,
[ShowLatestNewsFlag] [bit] NOT NULL,
[SortRowNumber] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL,
[CreatedBy] [nvarchar](20) NOT NULL,
[UpdatedDate] [datetime] NOT NULL,
[UpdatedBy] [nvarchar](20) NOT NULL,
[DeletedDate] [int] NULL,
[eCrewID] [varchar](10) NULL,
[EntityTypeID] [int] NOT NULL
)
GO
and here is my class:
public class Users
{
public Int32 ID { get; set; }
public String UserName { get; set; }
public Byte[] UserPassword { get; set; }
public Byte UserTypeID { get; set; }
public Boolean ByPassAccessRestrictionsFlag { get; set; }
public Boolean IsEnforcePasswordPolicy { get; set; }
public DateTime PasswordExpirationDate { get; set; }
public Boolean IsPwdChangeNextLogin { get; set; }
public Boolean ShowLatestNewsFlag { get; set; }
public Int32 SortRowNumber { get; set; }
public DateTime CreatedDate { get; set; }
public String CreatedBy { get; set; }
public DateTime UpdatedDate { get; set; }
public String UpdatedBy { get; set; }
public Int32 DeletedDate { get; set; }
public String eCrewID { get; set; }
public Int32 EntityTypeID { get; set; }
}
running a simple code:
var repo = new SimpleRepository("kiss", SimpleRepositoryOptions.None);
var users = repo.All<Users>();
gvUsers.DataSource = users;
gvUsers.DataBind();
yield an error:
System.Data.SqlClient.SqlException was unhandled by user code
Message="Invalid object name 'Users'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=208
Procedure=""
Server="(local)\\SQLEXPRESS"
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry)
at SubSonic.Linq.Structure.DbQueryProvider.Execute[T](QueryCommand`1 query, Object[] paramValues)
at lambda_method(ExecutionScope )
at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression)
at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
at SubSonic.Linq.Structure.Query`1.System.Collections.IEnumerable.GetEnumerator()
at System.Web.UI.WebControls.PagedDataSource.GetEnumerator()
at System.Web.UI.WebControls.GridView.CreateAutoGeneratedColumns(PagedDataSource dataSource)
at System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource dataSource, Boolean useDataSource)
at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.GridView.DataBind()
at web_subsonic._Default.Page_Load(Object sender, EventArgs e) in C:\scr\wcsf_playground\Modules\web_subsonic\web_subsonic\Default.aspx.cs:line 25
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: