subsonic3

SubSonic 3 - Simple repository - One to many relations

别来无恙 提交于 2019-12-08 04:55:00
问题 It's the first time I use Subsonic. Let say I have those classes : public class Store { public int Id { get; set; } public String Name { get; set; } } public class Employee { public int Id { get; set; } public String Name { get; set; } } An employee is related to a store with is hired date. This means that in the database I will have a middle table With StoreId, EmployeeId, StartDate, EndDate UPDATE An employee can work to the StoreA from 2009-01-01 to 2009-04-04 and work for StoreB from 2009

Subsonic 3 ActiveRecord nested select for NotIn bug?

偶尔善良 提交于 2019-12-08 01:01:27
问题 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

subsonic 3.0 , The SqlServer default value doesn't work?

喜夏-厌秋 提交于 2019-12-07 03:44:29
I used subsonic 3 with T4,It's very simple to use.But I get a problem now.I specify the default value in the sqlserver 2005.Then I called save() method in subsonic.I found the default value doesn't work. Default values won't work on inserts because your object will set the value first - whether it's null or ... whatever. The answer here is to set the default on the object. 来源: https://stackoverflow.com/questions/1171025/subsonic-3-0-the-sqlserver-default-value-doesnt-work

SubSonic 3 - Simple repository - One to many relations

拜拜、爱过 提交于 2019-12-06 15:56:35
It's the first time I use Subsonic. Let say I have those classes : public class Store { public int Id { get; set; } public String Name { get; set; } } public class Employee { public int Id { get; set; } public String Name { get; set; } } An employee is related to a store with is hired date. This means that in the database I will have a middle table With StoreId, EmployeeId, StartDate, EndDate UPDATE An employee can work to the StoreA from 2009-01-01 to 2009-04-04 and work for StoreB from 2009-04-05 to ... And I don't want that my data table repeat all the information of my employee each time

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 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

use subsonic 2.x and 3.x in the same project

余生长醉 提交于 2019-12-05 17:00:37
Is it possible to mix them? I'm asking because I have a big project that uses Subsonic 2.x generated classes (in a compiled dll) but would like to start using 3.x for new stuff. I tried it last night with a project where I had references to both subsonic.dll and subsonic.core.dll but that didn't work with ambiguous references, etc. So removed 2.x and then got an issue with my older compiled subsonic generated classes in that they needed Subsonic 2.1 to run. Hmm... I think there's a small chance that you might be able to do this, but you'd need to use the full qualifying class names (namespace

Parent and Child object in SimpleRepository

三世轮回 提交于 2019-12-05 14:34:34
How would it work in Subsonic's SimpleReporitory if I wanted to be able to have a 1 to many relationship between objects? Would I have to create a bridge object and then build my parent object at runtime, or is this support built in? What I am looking for is the folowing: Adam's Example Shop... Public Class Shop Private m_id As Integer Private m_Name As String Private m_Employees As List(Of Employee) Public Property Id() As Integer Get Return m_id End Get Set(ByVal value As Integer) m_id = value End Set End Property Public Property Name() As String Get Return m_Name End Get Set(ByVal value As