subsonic3

subsonic 3.0 active record update

I am able to retrieve database values and insert database values, but I can't figure out what the Update() syntax should be with a where statement. Environment -> ASP.Net, C# Settings.ttinclude const string Namespace = "subsonic_db.Data"; const string ConnectionStringName = "subsonic_dbConnectionString"; //This is the nam...

error while mapping MySQL database schema

Trying to map MySQL database schema using SubSonic 3, I get "Running transformation: System.InvalidOperationException: Sequence contains more than one matching element..." on all tables with a multiple-column Primary Key. Indeed, from the following MySQL.ttinclude code, it appears that you get only one PK column per table. i...

How to get random list of rows using subsonic 3

hello I am using Active record pattern of SubSonic 3 version. My requirement is to get 3 random rows from the Table. After some googling I found out that I can use NewID function in SQL but I dont know to get the Randow rows using sub sonic Thanks ...

SubSonic 3 - Retrieve values from dirty columns.

Hi, I am using SubSonic 3.0.0.4 with the ActiveRecord T4 Templates. I am hooking into OnSaving and getting a list of dirty columns that are about to be saved. What I cannot figure out is how to get each of the dirty columns values. Can someone assist? TIA - Mike ...

Stored Procedure with SimpleRepository

Hi, How to I execute a Stored Procedure with SimpleRepository and get a Typed List as a answer? I'm using SubSonic 3. Thanks. ...

Subsonic 3: Strongly typed return value for stored procedures that return mixed results from different tables

Say I have a stored procedure that returns dataSet from 2 different tables. Example: SELECT Customers.FirstName, Customers.LastName, SUM(Sales.SaleAmount) AS SalesPerCustomer FROM Customers LEFT JOIN Sales ON Customers.CustomerID = Sales.CustomerID GROUP BY Customers.FirstName, Customers.LastName Is there any way to get a strongly ty...

LINQ Query leaves all items with _IsTrue = true

Hi All, I have the following simple LINQ query (SubSonic 3.0.0.4 and ActiveRecord T4 templates). from item in PermissionsInRole.All() where item.RoleID == roleID select item When I iterate through the elements in the list after executing the query, IsNew = true for all of them, so if I make a change to an item and call.Save() it tri...

Forcing subsonic to ignore a certain pattern of column names

We use SubSonic as an ORM of sorts(really more of a query-helper). For one reason or another, we have a bit of a dynamic schema and as such certain tables have generated column names and such. Well, this has been all fine and dandy until now. Now, our production generated columns don't match up with our development generated columns. The...

Linq and SubSonic - returning nested complex types

Hi all, I'm new to SubSonic and reasonably new to LINQ as well, so I'm just trying to put a little app together. I've got the templates all sorted and running okay, but I've run into a bit of trouble with this LINQ statement (simplified slightly, the real statement has some other joins but they don't affect this particular problem so I'...

Funky Sql Generated using SubSonic Simple Repository, LINQ and ASP.NET MVC

I have the following code: if (collection["Filter"] == "2") { presentations = presentations.Where(x => x.Speaker.FirstName.StartsWith("B")). OrderBy(x => x.Speaker.FirstName); } this generates the following sql: SELECT [t0].[Description], [t0].[EventId], [t0].[Id], [t0].[PresentedOn], [t0].[Slug], [t0].[SpeakerId], ...

LINQ issue when deployed to WinHost.

I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything seems to work well locally, but when I deployed it to WinHost, I keep getting an exception like so: System.TypeAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Data.Common.DbDataReader)' to access...

SubSonic3 SimpleRepository Relationships Generated are Wrong

I have been told that it's more than likely my database that is setup wrong causing the problems so below are my tables with key fields and queries. CREATE TABLE Presentations ( Id INT NOT NULL IDENTITY(1, 1), SpeakerId INT NOT NULL, CONSTRAINT PK_Presentations PRIMARY KEY (Id), CONSTRAINT FK_Presentations_Speaker FOREI...

How do you update multiple rows in subsonic?

I want to update multiple rows in my SQL database using subsonic but I can't figure out how to do it. What's the easiest way of doing it? It would be something like this in sql : UPDATE table SET rowItem = 4 WHERE row_item = 3 ...

The member <some column> is not supported in SubSonic

Hello, I am using the T4 templates of SubSonic 3.0 to generate classes and such for me. Well in my database I have a Zipcode table with these columns ZipCode_rid Zipcode (the actual zipcode in number format) State etc Well, when the T4 templates run, instead of having a column like Zipcode.Zipcode I get Zipcode.ZipcodeX. Then, when t...

Creating T4 template file referring SubSonic

I am trying to write T4 template to create wrapper classes for classes created by SubSonic 3 (implementing IActiveRecord). But when I compile my template I get following error: Compiling transformation: Metadata file 'SubSonic.Core' could not be found I'm including SubSonic.Core in my settings file. <#@ assembly name="SubSonic.Core" #...

Subsonic 3.0 How to retrieve all users that belong to specific group in a many to many relationship

Lets say I have a many-to-many relationship: Group table User table group_user table which is a many to many table Given the group name I would like to find all the users that belong to this group. How can I do this with subsonic 3.0? IQueryable<group_user> groupUser= group_user.All(); Is it possible from groupUser to get all use...

Subsonic 3 query with aggregate error

Hello, I'm creating a simple query with aggregates. The example is: string query = new SubSonic.Query.Select( SubSonic.Query.Aggregate.GroupBy("ProductID", "ID"), SubSonic.Query.Aggregate.Max("Price", "MaxPrice") ).From("Orders").ToString(); The Sql Result is: SELECT ProductID AS ID, MAX(Price) AS MaxPrice FROM [Orders...

Nested linq - where x == enumerable

I'm new to Linq and SQL terminology - can someone tell me why this isn't working (syntax is not right - I can't compare u.UserID int with an Enumerable) var projectUsers = from u in SimpleRepository.All<User>() where u.UserID == (from i in SimpleRepository.All<ProjectUser>() where...

SubSonic Bug with TOP keyword?

The TOP keyword in the generated SQL wraps the number in brackets (I persume for SQL compact support), however this errors on my SQL 2000 server as it doesn't expect the brackets. Example C# Code: var doc = Logic.Document.All().FirstOrDefault(d=> d.Guid == Request.QueryString["guid"]); Produces the following SQL error: Line 1: In...

problem when binding mysql tinyint with subsonic 3 and datagridview

i created a datalayer using subsonic. however when i am selecting my data, i get the following exception. System.ArgumentException was unhandled Message="Object of type 'System.Boolean' cannot be converted to type 'System.SByte'." Source="mscorlib" StackTrace: at System.RuntimeType.CheckValue(Object value, Binder binder...