subsonic

Subsonic 3 - Update NullReferenceException

江枫思渺然 提交于 2019-12-06 15:18:24
I am using Subsonic v3.0.0.3 with the Linq templates. I am attempting to update a record in a SQL Server Express database with the following: var db = new MyDB(Constants.Database); db.Update<Contact>() .Set(d => d.FirstName == contact.FirstName) .Where(d => d.Id == contact.Id) .Execute(); I am receiving a NullReferenceException when this line is executed. The stack trace is as follows: at SubSonic.Query.Update.GetCommand() at SubSonic.Query.Update.Execute() Any chance that someone may be able to suggest what the problem is? Hmm - I would say to make sure the connection string is present (I'll

Defining SubSonic 3 ActiveRecord migrations

爱⌒轻易说出口 提交于 2019-12-06 12:43:30
问题 I'm starting an ASP.NET MVC project using SubSonic 3 ActiveRecord. I added a table Users with a primary key ID and recompiled T4 files to generate User class. I want to make sure that, as I go along with the development, I can regenerate/migrate the database at any point. It looks like I have to create tables and relationships in the database, regenerating ActiveRecord classes and doing migration as described in http://subsonicproject.com/docs/3.0_Migrations. The old 2.x way of defining

SubSonic SimpleRepository Updates Cause Null Reference Exceptions

故事扮演 提交于 2019-12-06 12:37:26
问题 In researching the SubSonic's new SimpleRepository, I've found that calling the Update() method always throws a NullReferenceException . This is even true in the sample MVC download that's included with the 3.0.0.3 release. Does anyone know if there's a way to get updates to succeed? Here's an example. The if statement works; it adds the table and creates the record. Running this code a second time flow to the else block, and the update throws the exception. var repo = new SimpleRepository("c

SubSonic and Stored Procedures

╄→尐↘猪︶ㄣ 提交于 2019-12-06 11:48:46
问题 When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object? I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object. If you used a MVC, do you usually use the StoredProcedure object or wrap that around your business logic and return a dataset, list, collection or something else? Are datasets still the norm or is that

Subsonic Query (ConditionA OR ConditionB) AND ConditionC

♀尐吖头ヾ 提交于 2019-12-06 07:56:42
问题 How do I build a query in Subsonic that of this format (ConditionA OR ConditionB) AND ConditionC Iv tried various approaches but I cant seem to get the desired result. Here is one thing i tired: Query q = Challenge.CreateQuery(); q.WHERE(Challenge.Columns.ChallengeeKey, playerKey) .OR(Challenge.Columns.ChallengerKey, playerKey); q.AND(Challenge.Columns.Complete, false); 回答1: If you use 2.2 (or 2.1) you can open up expressions: Northwind.ProductCollection products = new Select(Northwind

Use the Subsonic.Select() ExecuteTypedList Method with String

眉间皱痕 提交于 2019-12-06 06:20:26
This is more a question regarding generics than subsonic: Imagine if have the following code: List<int> result = DB.Select(Product.Columns.Id) .From<Product>() .ExecuteTypedList<int>(); That works great and returns a generic list with the ids from my Product table. But if I want to get a list of the ProductName: List<String> result = DB.Select(Product.Columns.ProductName) .From<Product>() .ExecuteTypedList<String>(); it throws a compiler message (translated from german): "string" has to be a non-abstract type with a public Constructor without parameter, in order to be used as a generic type or

what happened to the subsonic screencasts?

拥有回忆 提交于 2019-12-06 05:51:35
None of them are available in the docs. I see embedded iframes pointing to "silverlight.services.live.com", but no video. FF shows blank, IE7 shows HTTP 500 error. Silverlight live streaming - the MS service launched to support things like this - went offline and I need to move every single one of the screencasts I've made for SubSonic over the last 3 years. This is going to take some time - I'll get there but it will be a few weeks. 来源: https://stackoverflow.com/questions/2252288/what-happened-to-the-subsonic-screencasts

Subsonic 3 ActiveRecord nested select for NotIn bug?

那年仲夏 提交于 2019-12-06 04:24:40
I have the following Subsonic 3.0 query, which contains a nested NotIn query: public List<Order> GetRandomOrdersForNoReason(int shopId, int typeId) { // build query var q = new SubSonic.Query.Select().Top("1") .From("Order") .Where("ShopId") .IsEqualTo(shopId) .And(OrderTable.CustomerId).NotIn( new Subsonic.Query.Select("CustomerId") .From("Customer") .Where("TypeId") .IsNotEqualTo(typeId)) .OrderDesc("NewId()"); // Output query Debug.WriteLine(q.ToString()); // returned typed list return q.ExecuteTypedList<Order>(); } The internal query appears to be incorrect: SELECT TOP 1 * FROM [Order]

How to intersept the save method on ActiveRecord on SubSonic ORM?

青春壹個敷衍的年華 提交于 2019-12-06 04:06:14
问题 I need to intercept the Save method, do some validations, alter some properties and then let it go again normally. How can I do this? Thanks! Alex 回答1: I would recommend adding the following partial methods to be fired before their actual action: OnSave(CancelEventArgs e); OnAdd(CancelEventArgs e); OnUpdate(CancelEventArgs e); OnDelete(CancelEventArgs e); This isn't an event but I would use CancelEventArgs anyway, it's friendly, people know it and know how to use it and with it the actual

SubSonic with MS SQL 2008?

随声附和 提交于 2019-12-06 01:21:33
I have been using subsonic with MS SQL 2005 for about a year now. For those of you who have moved to SQL 2008, is subsonic compatiable with that? Have you had too many issues with SubSonic with SQL 2008? Just trying to get a feel if I should upgrade to SQL 2008 at this time or not. Thanks I've not used SQL2008 myself, but I know there is still a bug in SubSonic 2.1 and 2.2 in handling the new date only and time only data types (it sees them as strings). SubSonic works great with Sql Server 2008. If you are at all worried you can download the source and add a reference to the project so that