Oracle Stored Procedures in SubSonic 2.2 - oracle

I'm still not getting my SP's generated in SubSonic 2.2 against an Oracle 10g DB. The Tables and Views generate up perfectly. Also this product is multiplatform so we're gen'ing up SubSonic libraries against SQL 2K5 and that works great for Tables/Views and SP's.
I recall on the old forums there was a bug in earlier versions of the Provider, so I'm not sure if this is still the same issue, or if I'm doing something wrong on my end? Also SubStage (the UI) chokes when invoking the provider on Oracle (no issues with SQL). So I'm figuring there's something in the SPs that are choking it [?]
Thanks! Real close to migrating to SS from our current home grown DAL.

I was able to fix a lot of the issues with the Oracle Provider in SubSonic in version 2.1 and most all of my fixes made it into 2.2. I didn't work on fixing the SP generation portion of the Oracle Provider as I only had one or two SPs. Even if the SP generation isn't working you can still use SPs with the Oracle Provider. I simply added the SPs by hand (see below) as a partial class in the altered folder I use to add functionality to the classes SubSonic generates.
example
public partial class SPs
{
public static decimal CreateSp(string username, string labelNote)
{
Decimal returnId = 0;
SubSonic.StoredProcedure sp = new StoredProcedure("User.MySP");
sp.Command.Parameters.Add("username", username, DbType.String);
sp.Command.Parameters.Add("labelnote", labelNote, DbType.String);
sp.Command.Parameters.Add("returnId", returnId, DbType.Decimal, ParameterDirection.Output);
sp.Execute();
return Convert.ToDecimal(sp.Command.Parameters.Find(delegate(QueryParameter qp) { return qp.ParameterName == "returnId"; }).ParameterValue);
}
}

Related

ValidateAntiForgeryToken breaks read on .NET Core with IdentityServer4

I am doing a basic read and write functionality to a IdentityServer4 application using .NET Core 2.0 and have come across an issue. When trying to load clients the ValidateAntiForgeryToken attribute seem to break my update.
I know that EF core does not support lazy loading so we are using an Unit Of Work pattern. I would create separate repositories for Client, ClientScopes, Secrets, etc. and grab the data for each. I will pass in a Func<> to allow filtering when grabbing ClientScopes etc. So a method call would look like this
ClientScopeResitory.GetAll(a => a.Client.Id == id)
which would then access the dbset like this
public IEnumerable GetAll(Func<T, object> predicate == null)
{
return predicate != null ? dbset.Where(predicate) : dbset
}
My issue is when loading the client in my read operation this works just fine. However when using the same code in my update where the ValidateAntiForgeryToken is present it breaks. What happens is in the creation of the repository during the read, the Clients are loaded in with the dbset. However, in the update, the clients are not. When the ValidateAntiForgery attribute is removed. The clients are loaded again and the update works fine. Anyone have any ideas what is going on. I can supply full code upon request. Thanks in advance.
Also, I apologies for any bad grammar or spelling, I wrote this in a hurry

EF Core 2.0 Invalid Column Error from ASP.NET Core UserManager

Have started new ASP.NET Core 2.0 and EF Core 2.0 project. The project uses the built in Identity table schema. Every time I make any call to the built in UserManager that uses any of the Roles or Claims tables the call fails with a "Invalid Column" error. I added Serilog so I could see all logging and EF Core generated SQL. EF Core is adding the same invalid column name "BlogUserId" to all the select queries that are failing thus the invalid column error. That string does not exist in the code anywhere including the EF Core Migrations code that generates the database and tables. Where is Entity Framework picking up this column?
SELECT TOP(1) [e].[UserId], [e].[RoleId], [e].[BlogUserId]
FROM [AspNetUserRoles] AS [e]
WHERE ([e].[UserId] = #__get_Item_0) AND ([e].[RoleId] = #__get_Item_1)
System.Data.SqlClient.SqlException (0x80131904):
Invalid column name 'BlogUserId'.
You can see where the column gets added to the generated query but that column is not part of the table schema nor is it in code anywhere. How do I fix this issue or can someone tell me what is causing this?
Thanks to Ivan Stoev the solution was found. The BlogUser class was a carry over from the old web site which was ASP.NET Core 1.1. It had additional properties but also had two navigation properties as below to store user Roles and Claims which had worked perfectly. After commenting these to navigation properties every thing seems to work as expected.
public virtual ICollection<IdentityUserRole<string>> Roles { get; } = new List<IdentityUserRole<string>>();
public virtual ICollection<IdentityUserClaim<string>> Claims { get; } = new List<IdentityUserClaim<string>>();

Fluent NHibernate / NHibernate via NuGet for SQL2012

I've just installed the following latest packages from NuGet:
FluentNHibernate.1.3.0.733
NHibernate.3.3.2.4000 (was required for FNH)
I'm trying to get our ASP.NET MVC 3 app running using SQL 2012 (native).
The following code is taken from our method which builds our nhibernate Session:
var sqlConfig = MsSqlConfiguration.MsSql2005.ConnectionString(ConnectionString).AdoNetBatchSize(30);
We also use this approach for provisioning a new emtpy DB using the code first approach.
I need to use the SQL 2012 dialiect but neither the latest FNH or NHibernate have it from NuGet.
Does anyone kow the status of the code in Git for these? I can see a merge for FNH for this 2012 dialiect was done 7 months ago (a month after the latest NuGet was released).
What are others doing to connect to SQL 2012?
Does anyone know when the next NuGet packagaes for these will be available?
Just use the SQL Server 2008 dialect. I don't know of any changes in 2012 that would require an update to the dialect.
It's already supported by the NHibernate core, so it's just a matter of using MsSql2012Dialect:
var sqlConfig = MsSqlConfiguration.MsSql2005.Dialect<MsSql2012Dialect>();
MsSqlConfiguration.MsSql2012 was added to Fluent shortly after the latest release, so you can grab the source if you want, but the end result is the same.
My current setup is using NHibernate (3.3.2.4000) and FluentNHibernate (1.3.0.733) and the first part of my connection setup looks like this, feel free to adapt it to your needs. Note that even though I pull the connection string using the MsSql2008 configuration class, I have set my dialect to MsSql2012Dialect
var cfg = Fluent.NHibernate.Cfg.Fluently.Configure()
.Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
.ConnectionString(c => c.FromConnectionStringWithKey("KeyName"))
#if DEBUG
.ShowSql()
.FormatSql()
#endif
.Dialect<NHibernate.Dialect.MsSql2012Dialect>()
.AdoNetBatchSize(50)
)
//Other chained methods (for setting up cache, mappings, etc)
//.Mappings(m =>
//{
//
//}
var sessionFactory = cfg.BuildSessionFactory();
from what I can see the 2012 Dialect just adds support for Sequences and registers iif as a function.

Web Api and Odata without Entity Framework

I am having trouble getting OData to work with Asp.Net Web Api when the underlying data is NOT coming from Entity Framework.
I am using the latest OData Nuget package (Microsoft ASP.NET Web API OData 0.2.0-alpha release) but when I attempt to pass an OData query (say $top=10) I receive the error:
The given key was not present in the dictionary
If I don't send an OData query I can call the method just fine. The other methods in the same Web Api project that use Entity Framework work fine with OData queries. The one's that don't work are using Subsonic ORM to query an underlying AS400 data source. It returns an IQueryable. This worked just fine before the VS 2012 and .NET 4.5 RTM was released and OData was moved into a separate package. (i.e. worked with beta and RC versions of VS2012 and .NET 4.5)
Any ideas would be appreciated.
I guess this issue is caused by stable ordering, which doesn't work well with the underlying query provider. Could you put the call stack of the error to confirm it?
One big change with OData query composition in this release is that it ensures stable ordering before taking top items. The reason to do that is user may have random data source which makes return data keep changing.
The way web api odata package does is to add OrderyBy [Keys] query before executing top. Or if there is no key defined in the model (Keys are ID, EntityID, or [Key] attributed property), it will use all the primitive properties in the model to order.
If you can make sure that the data source will always return data with stable ordering, you can turn off this feature by code:
[Queryable(EnsureStableOrdering = false)]

InnerException {"Invalid object name 'dbo.Users'"}

I am currently trying to setup an ASP.Net MVC 3 Application for the first time. I know what I am doing with Ruby on Rails but completely lost with ASP.Net. I would like the app to create the database but not sure what I am doing wrong. I have an empty Database build called ssDB. I have setup the connectionStrings and built out the Model classes. According to everything I have read thus for, when I go to the run the App it should create the database but it doesn't look that way.
The Abbreviated Error I get is:
InnerException: System.Data.SqlClient.SqlException
Message=Invalid object name 'dbo.Users'.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=208
Procedure=""
Server=TESTSVR01
State=1
I have an empty Database build called ssDB
You have created an empty database with no tables. Since there is a database EF assumes tables are also created. Hence it will not proceed to create the tables.
You can drop the database and allow EF to create the database and the tables.
I also experienced the same issue while using Database first approach. Connection string in my service's/service's host web.config was incorrect. I corrected the connection string and it worked.

Resources