subsonic

How does Subsonic handle connections?

心不动则不痛 提交于 2019-12-23 19:43:39
问题 In Nhibernate you start a session by creating it during a BeginRequest and close at EndRequest public class Global: System.Web.HttpApplication { public static ISessionFactory SessionFactory = CreateSessionFactory(); protected static ISessionFactory CreateSessionFactory() { return new Configuration() .Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hibernate.cfg.xml")) .BuildSessionFactory(); } public static ISession CurrentSession { get{ return (ISession)HttpContext.Current

SubSonic 3.0.0.2 Structs.tt

﹥>﹥吖頭↗ 提交于 2019-12-23 12:23:44
问题 The error I'm getting seems to be coming out of the Structs.tt file. I'm using the Northwind db and only using the Products table (I excluded all other tables). I return Json(Product.All()). Here's the error: A circular reference was detected while serializing an object of type 'SubSonic.Schema.DatabaseColumn'.Here's the Stack Trace: System.InvalidOperationException was unhandled by user code Message="A circular reference was detected while serializing an object of type 'SubSonic.Schema

Subsonic + Sqlite + Float datatype == “Can't save: xxx exceeds the maximum length of 8”

夙愿已清 提交于 2019-12-23 04:56:09
问题 I'm building a data loader utility application (Win 7 64bit, VS 2008, C#, .Net 3.5, Win Forms) using Subsonic 2.2. I've gotten everything working using SqlServer and now I need to get it working in Sqlite 3. I've worked through some issues but there is one I cannot resolve; I have 2 columns, Latitude and Longitude that are FLOAT data types in sqlite and Subsonic generates as nullable floats. The code generation is fine, building is fine but when I attempt to run the application, when the

Subsonic 3 and The Adjacency Model

核能气质少年 提交于 2019-12-23 04:37:05
问题 If a table has the adjacency model applied (ID,ParentID) how can the hierarchy be returned in Subsonic 3? 回答1: All classes are partials, so create a new partial for your class (let's say it' Category) and create child collection (call it SubCategories). Then when you load your object into memory you can load the subcollection: var allCategories=Categories.All().ToList(); allCategories.ForEach(x=>x.SubCategories=allCategories.Where(y=>y.CategoryID==x.ParentID)); That's freehanded, but that's

Atomically increment a field using SubSonic 3 ActiveRecord

落爺英雄遲暮 提交于 2019-12-23 03:18:21
问题 I'm tring to increment a field in a MySQL database using SubSonic 3 ActiveRecord. In SQL, this is what I'm after: UPDATE people SET messages_received=messages_received+1 WHERE people_id=@id_to; I tried the following, but it didn't seem to work (messages_received always seemed to be 1): _db.Update<person>() .Set("messages_received").EqualTo(x => x.messages_received == x.messages_received + 1) .Where(x => x.people_id == idTo) .Execute(); This did work: string sql="UPDATE people SET messages

Locking problems with sqlite and SubSonic when using transactions on a single thread

a 夏天 提交于 2019-12-23 01:19:06
问题 I'm getting locking exceptions when trying to use transactions with SubSonic and SQLite. I'm using this from a single thread and there are no other processes accessing my db, so I really didn't expect any such problems. If I write code like this below, I get an exception on the second call to Save() within the loop - so the third call to Save() over all. using (TransactionScope ts = new TransactionScope()) { using (SharedDbConnectionScope sharedConnectinScope = new SharedDbConnectionScope())

Use the Subsonic.Select() ExecuteTypedList Method with String

我是研究僧i 提交于 2019-12-22 18:42:12
问题 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

Object mapping with LINQ and SubSonic

萝らか妹 提交于 2019-12-22 00:29:43
问题 I'm building a small project with SubSonic 3.0.0.3 ActiveRecord and I'm running into an issue I can't seem to get past. Here is the LINQ query: var result = from r in Release.All() let i = Install.All().Count(x => x.ReleaseId == r.Id) where r.ProductId == productId select new ReleaseInfo { NumberOfInstalls = i, Release = new Release { Id = r.Id, ProductId = r.ProductId, ReleaseNumber = r.ReleaseNumber, RevisionNumber = r.RevisionNumber, ReleaseDate = r.ReleaseDate, ReleasedBy = r.ReleasedBy }

MVC.net + subsonic Auto Generate MetaData Classes from TT

六月ゝ 毕业季﹏ 提交于 2019-12-21 05:58:23
问题 Not a question but i dont have a blog and i have just created a new subsonic TT file that will generate the Metadata classes automatically for the subsonic classes so you can skip out some work when using dataAnnotation and CreateForModel etc so the first step is to amend your ActiveRecord.TT with the following using System.ComponentModel; using System.Data.Common; using System.ComponentModel.DataAnnotations; Then above the generation of the class name we need to make a reference to our

Using transactions with subsonic

一世执手 提交于 2019-12-21 00:03:27
问题 In my web application I've to keep audit of the user actions. So whenever user takes an action I update the object on which action is taken and keep audit trail of that action. Now If I first modify the object and then update audit trail but the audit trail fails then what? Obviously I need to roll-back changes to modified object. I can use Sql-Transactions in simple application, but I'm using Subsonic to talk to db. How I can handle the situation? 回答1: Something like: Using ts As New System