Hi,
as a sample I have defined a view View1 in a database SimpleDB being a projection of the table Table1 defined in a different database SourceDB.
Using the designer I've create a LightSpeedModel accordingly importing View1 only.
Whereas using the same setup with Linq2Sql everything works fine, if I try to load the data of View1 using a LightSpeed UnitOfWork I always receive an "Invalid object name" exception (see StackTrace below).
Why is that?
Regards,
Remo Ronca
----- Definition of SimpleDB.dbo.View1
SELECT SourceDB.dbo.Table1.ID, SourceDB.dbo.Table1.Name
FROM SourceDB.dbo.Table1
----- app.config
<configuration>
<configSections>
<section name="lightSpeedContexts" type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed"/>
</configSections>
<connectionStrings>
<add name="Dev" connectionString="Data Source=xxxxxxxxxxxx;Initial Catalog=SimpleDB;Integrated Security=True;Pooling=False;Encrypt=True"></add>
</connectionStrings>
<lightSpeedContexts>
<add name="default" connectionStringName="Dev" dataProvider="SqlServer2005"></add>
</lightSpeedContexts>
</configuration>
------ sample code
LightSpeedContext<SimpleDBUnitOfWork> context;
context=new LightSpeedContext<SimpleDBUnitOfWork>("default");
BindingSource bs=new BindingSource();
using(var uow=context.CreateUnitOfWork())
{
bs.DataSource=uow.View1; // throws exception
}
System.Data.SqlClient.SqlException was unhandled
Message="Invalid object name 'View1'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=208
Procedure=""
Server="xxxxxxxxxxxxxxxxxxxxxxxxxx"
State=1
StackTrace:
bei System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
bei System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
bei System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
bei System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
bei System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
bei System.Data.SqlClient.SqlDataReader.get_MetaData()
bei System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
bei System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
bei System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
bei System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
bei System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
bei ...()
bei ..(IUnitOfWork , IDbCommand , )
bei ..(IUnitOfWork , IDbCommand )
bei ...ctor(IUnitOfWork , IEnumerable`1 )
bei Mindscape.LightSpeed.Data.DataProviderAdapter.(IUnitOfWork , IEnumerable`1 )
bei ..(TypeModel , Query , IList )
bei ..(UnitOfWorkBase , TypeModel , Query , IList )
bei ..(Query , TypeModel , IList )
bei ..(Query , IList )
bei Mindscape.LightSpeed.UnitOfWork.Find(Query query, IList results)
bei Mindscape.LightSpeed.UnitOfWorkBase.Find(Query query)
bei Mindscape.LightSpeed.Linq.Plan.SingleQueryPlan.ExecuteImmediate(IUnitOfWork unitOfWork, Type returnType)
bei Mindscape.LightSpeed.Linq.LinqQueryProvider.Execute(Expression expression)
bei Mindscape.LightSpeed.Linq.LinqQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
bei Mindscape.LightSpeed.Linq.LinqQuery`1.System.Collections.IEnumerable.GetEnumerator()
bei System.Windows.Forms.BindingSource.GetListFromEnumerable(IEnumerable enumerable)
bei System.Windows.Forms.BindingSource.ResetList()
bei System.Windows.Forms.BindingSource.set_DataSource(Object value)
bei WindowsFormsApplication13.Form1..ctor() in F:\Source\WindowsFormsApplication13\WindowsFormsApplication13\Form1.cs:Zeile 27.
bei WindowsFormsApplication13.Program.Main() in F:\Source\WindowsFormsApplication13\WindowsFormsApplication13\Program.cs:Zeile 18.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException: