Basically, I'm having the same problem as detailed here, but in SubSonic 3.0. Unfortunately, I can't figure out how to change the provider in SubSonic 3.0.
Is this something I need to change in the MySQL.ttinclude, Settings.ttinclude or one of the T4 templates? Or does it go in config somewhere?
Thoughts? Suggestions?
I found this that says that it's as designed. I can't imagine why. I changed the Classes.tt file to generate a single mapping. The relevant code is below. However, this relies on the fact that all my PKs are named Id, but you should be able to get the idea.
Before the IQueryable<> generation part:
if (fk.ThisColumn == "Id")
{
//This is where the standard IQueryable goes
} else {
//This is what I added
public <#= fk.OtherTable #> <#= fk.OtherTable #>
{
get
{
var db=new <#=Namespace #>.<#=DatabaseName#>DB();
return from items in db.<#=fk.OtherQueryable #>
where items.<#=fk.OtherColumn#> == _<#=fk.ThisColumn#>
select items;
}
}
}
Hopefully that helps. I'm trying to figure out now to do many to many tables now :/
I am using Subsonic 2.2 and I am facing the same issue, but this worked on my problem: Apart from original provider MySqlDataProvider, there is an extended version: MySqlInnoDBDataProvider
So in your web.config, making sure the provider is choosn:
<add name="MyProvider"
type="SubSonic.MySqlInnoDBDataProvider, SubSonic"
connectionStringName="WriteConnectionString"
generatedNamespace="AttendAnywhere.Data"
generateLazyLoads="true"
extractClassNameFromSPName="true" />
Related
first of all, if any developper of the lib spring-data-cassandra read me : Thank you for your work, the lib is working like a charm and is well integrated to spring project.
Here is, a few days ago i was facing a problem when trying to use pagination in cassandra. I found a workaround to my problem and will explain how did i do that.
My problem is the following, i've been using pagination for cassandra and i've had to iterate over the slices of results and it worked until i decided to use Sort in pagination.
To achieve that i've used:
-a service using a Repository extending CassandraRepository
here is the code (the service wrapping the repository)
public Slice<Pony> getAllByTypePage(Pageable p, EnumType type) {
Slice<Pony> slice = ponyRepository.findAllByType(p.first(), type);
//Iterate over slices
while(slice.hasNext()&&slice.getPageable().getPageNumber()<p.getPageNumber())
{
slice = ponyRepository.findAllByType(slice.nextPageable(), type);
}
return slice;
}
Pony is my Model en ponyRepository is my CassandraReposity
#Repository
public interface PonyRepository extends CassandraRepository<Pony,UUID> {
#Async
CompletableFuture<Long> countByType(EnumType type);
Slice<Pony> findAllByType(Pageable p,EnumType type);
}
When i try to get a page (other than the first one) i get this exception
com.datastax.driver.core.exceptions.PagingStateException: Paging state mismatch, this means that either the paging state contents were altered, or you're trying to apply it to a different statement
after some debugging i've seen that the pageable object i obtained in the slice.nextPageable() was in Sort.UNSORTED mode instead of having the sort of my input pageable.
then, knowing that i made this workaround:
public Slice<Pony> getAllByTypePage(Pageable p, EnumType type) {
Slice<Pony> slice = ponyRepository.findAllByType(p.first(), type);
//using a sidePageable and incrementing it in parallel
Pageable sidePageable = p.first();
//Iterate over slices
while(slice.hasNext()&&sidePageable.getPageNumber()<p.getPageNumber())
{
CassandraPageRequest cpr = CassandraPageRequest.of(sidePageable.next(), ((CassandraPageRequest)slice.getPageable()).getPagingState());
slice = ponyRepository.findAllByType(cpr, type);
sidePageable=sidePageable.next();
}
return slice;
}
the workaround seems to work.
Is this behavior is normal or is it a bug?
i have not seen any issues about this in the jira (maybe i did not looked at the good place).
here is the related libs i use (spring boot 2.2.1/spring code 5.2.1):
spring-data-cassandra : 2.2.1.RELEASE
cassandra-driver-core: 3.7.2
i have seen the same behavior on spring core 5.1.5
Best Regards
like said in the previous comments, it was a bug.
this is already fixed (see the issue linked before).
I just tried with the snapshot 2.2.2.BUILD-20191113.121102-4 and it seems to work.
for now i'll use my workaround. When the lib will be released i'll upgrade.
thanks for the help #mp911de
I am using the very excellent servicestack libaries and trying to generate a ASP.NET web-service reference (old style not WCF) from within VS2010 across my servicestack WSDL - Soap11. To nicely wrap the service WSDL.
The DTO's are in a seperate assembly/namespace (My.WS.DTO) from the AppHost/services and are following the request/response naming convention.. when I try to generate the reference through visual studio I get the following error in VS.
Custom tool error: Unable to import WebService/Schema. Unable to import binding 'BasicHttpBinding_ISyncReply' from namespace 'http://schemas.servicestack.net/types'. Unable to import operation 'GetMyDetails'. The element 'http://schemas.servicestack.net/types:GetMyDetails' is missing.
NOTE: GetMyDetails is just the first service that appears in the list - so I dont believe this is the problem.
I have tried adding the assembly namespace in the AppHost file using
EndpointHostConfig.Instance.WsdlServiceNamespace = "My.WS.DTO"; and this just causes the same generation error (as above) but with 'My.WS.DTO' instead of 'http://schemas.servicestack.net/types'.
I assume it is perhaps some sort of referencing problem but any guidance as to what I might be doing wrong would be great.
cheers
I don't know if this is still an issue for you but I had a similar problem and found that I had not decorated one of my DTOs with [DataContract] and [DataMember] attributes, as described on the SOAP Support wiki page. Once you have added these to your DTO it will be declared in the type section of the WSDL.
Have a look at using [DataContract (Namespace = "YOUR NAMESPACE")] on top of your DTO's. This is how my objects are referenced.
[DataContract(Namespace = "My.WS.DTO")]
public class Account{
}
I also use this in my service model. [System.ServiceModel.ServiceContract()] and [System.ServiceModel.OperationContract()]
[System.ServiceModel.ServiceContract()]
public class SendGetAccountResponseService : IService<SendGetAccountNotification>
{
#region IService implementation
[System.ServiceModel.OperationContract()]
public object Execute (SendGetAccountNotification request)
{
Console.WriteLine ("Reached");
return null;
}
#endregion
}
Hope this helps / solves your problem.
I know this is an old question, but I had to add SOAP support for a 3rd party that refused to support REST very recently to my ServiceStack implementation so it could still be relevant to other people still having this issue.
I had the same issue you were having:
Unable to import binding 'BasicHttpBinding_ISyncReply'...
And like mickfold previously answered I needed to add [DataContract] and [DataMember] to my class definitions and their properties.
But I also had to add the following to my AssemblyInfo.cs file before the error went away for me:
[assembly: ContractNamespace("http://schemas.servicestack.net/types", ClrNamespace = "My Type Namespace")]
I assume that you will need one of these lines for every single namespace where you have a type declared, which based upon the original question above would be My.WS.DTO.
I'm using EntityFramework 4.3 beta version and its Data Migration facility. I wrote following code for generating a custom Migration and apply it to the DB.
MigrationScaffolder ms=new MigrationScaffolder(configuration);
ScaffoldedMigration scaffoldedMigration= ms.Scaffold("Migration");
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(scaffoldedMigration.MigrationId);
Scaffolding function worked fine and generated a Migration correctly.
But an exception comes up and says
"The specified target migration '201201230637551_Migration' does not
exist. Ensure that target migration refers to an existing migration
id."
Does this happen since still this is a beta version? Can someone help me to solve this.
Thank you.
This is not because you were using a beta version. MigrationScaffolder class is only to generate a configuration class. That generated file is not being added to the solution automatically. If we want to pass it into DbMigrator.Update() method, we should add the generated file into the solution first. Then we should make an instance of that class, and pass it into the update() method like this.
{
DbMigrationsConfiguration myConfiguration=new MyConfiguration();
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(myConfiguration);
}
Here MyConfiguration is the generated class.
Additionally, you do not need to apply migrations into your project this way. Instead you can use:
{
DbMigrationsConfiguration myConfiguration=new DbMigrationsConfiguration(){
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
}
DbMigrator dbMigrator = new DbMigrator(configuration);
dbMigrator.Update(myConfiguration);
}
Is it possible to use ASP.NET Dynamic Data with SubSonic 3 in-place of Linq to SQL classes or the Entity Framework? MetaModel.RegisterContext() throws an exception if you use the context class that SubSonic generates. I thought I remembered coming across a SubSonic/Dynamic Data example back before SubSonic 3 was released but I can't find it now. Has anyone been able to get this to work?
I just got Subsonic 3.0.0.4 ActiveRecord working last night in Visual Studio 2010 with my SQLite database after a little bit of work and I've tried to document the steps taken here for your benefit.
Start by adding a New Item -> WCF Data Service to the project you're using to host your webapp/webservices then modify it similar to my PinsDataService.svc.cs below:
public class PinsDataService : DataService<PINS.Lib.dbPINSDB>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
At this point your Dynamic Data Service would probably be working if you matched all the database naming conventions perfectly but I didn't have that kind of luck. In my ActiveRecord.tt template I had to prepend the following two lines before the public partial class declarations:
[DataServiceKey("<#=tbl.PrimaryKey #>")]
[IgnoreProperties("Columns")]
public partial class <#=tbl.ClassName#>: IActiveRecord {
I then added references to System.Data and System.Data.Services.Client followed by the inclusion of using statements for using System.Data.Services and using System.Data.Services.Common at the top of the ActiveRecord.tt template.
The next step was to use the IUpdateable partial class implementation from this blog post http://blogs.msdn.com/aconrad/archive/2008/12/05/developing-an-astoria-data-provider-for-subsonic.aspx and change the public partial class dbPINSDB : IUpdatable to match my subsonic DatabaseName declared in Settings.ttinclude
Then to consume the data in a separate client app/library I started by adding a 'Service Reference' named PinsDataService to the PinsDataService.svc from my client app and went to town:
PinsDataService.dbPINSDB PinsDb =
new PinsDataService.dbPINSDB(new Uri("http://localhost:1918/PinsDataService.svc/"));
PinsDataService.Alarm activeAlarm =
PinsDb.Alarms.Where(i => i.ID == myAA.Alarm_ID).Take(1).ElementAt(0);
Note how I'm doing a Where query that returns only 1 object but I threw in the Take(1) and then ElementAt(0) because I kept getting errors when I tried to use SingleOrDefault() or First()
Hope this helps--also, I'm already aware that dbPINSDB is a really bad name for my Subsonic Database ;)
I downloaded today Subsonic 3 and tried out the examples. I am having a problem with the SimpleRepository example and I wondered if anyone else has had this. In the HomeController there is a defintion as follows:
public HomeController() {
_repo = new SimpleRepository("Blog");
}
I wanted to enable the migrations and so changed it to this:
public HomeController() {
_repo = new SimpleRepository("Blog", SimpleRepositoryOptions.RunMigrations);
}
However, when this runs it causes an error - stating an issue "String or binary data would be truncated.".
If it makes a difference, the version of VS is 2008 (with the GDR applied)
This is still an issue in the latest 3.0.0.1 and .2 downloads..
You get this error message if the migration you are trying to run would edit/truncate data in your database.
Do you have sql profiler available? That way you can see the sql statement. If you don't have sql profiler available you will need to download the source and use debug to see the actual sql statement that it is trying to execute.
Way way way late to this party, but you probably need to add the [SubSonicLongString] attribute to the columns that have more than the default 225 characters for a plain String.