Yet another newbie SubSonic/ActiveRecord question. Suppose I want to insert a couple of records, currently I'm doing this:
using (var scope = new System.Transactions.TransactionScope())
{
// Insert company
company c = new company();
c.name = "ACME";
c.Save();
// Insert some options
company_option o = new compan...
I'm having trouble saving a record in Subsonic 3 using Active record. I've generated my objects using the DALs and tts and everything seems fine because the following test passes. I think that my connection string is correct or the generation wouldn't have succeeded.
[Test]
public void TestSavingAnEmail()
{
...
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_receive...
I've been trying to use SubSonic 3.0's test repository support for unit testing but encountered a few issues, so I thought I document them, and the fixes I've come up with:
Auto-Increment Columns Don't Work
Obviously with no DB, auto-increment columns don't work automatically, but if like me you're using simple ints or longs for all id...
I need to filter the data retrieved from database adding clauses to the where in the SQL.
I'm trying to do this Using subsonic 3, but i'm getting an error... I'm lost!
SubSonic.Query.SqlQuery qry = new SubSonic.Query.SqlQuery();
qry.From<TFCore.Lugare>(); //I'm getting the error here "Object reference not set to an instance of an...
I'm getting an error while trying to load an record through the constructor.
The constructor is:
public Document(Expression<Func<Document,bool>> expression);
and i try to load a single item in like this
var x = new Document(f=>f.publicationnumber=="xxx");
publicationnumber isn't a key but tried making an it an unique key and stil...
I have been having issues trying to return distinct records from a subsonic3 query using VB. My base query looks like so:
Dim q As New [Select]("Region")
q.From("StoreLocation")
q.Where("State").IsEqualTo(ddlState.SelectedValue)
q.OrderAsc("Region")
This returns duplicates. How can I add a distinct cl...
I'm trying to use the built-in testing features of Subsonic 3.0.0.4 by setting my connection string to "Test". My data access routines use the SqlQuery class. When I try to run a test against the "in-memory" repository, I receive this error:
System.ArgumentException: Format of
the initialization string does not
conform to speci...
db.Update<Luna.Record.TB_ITEM>().Set(
x => x.ITEM_DURABILITY == Convert.ToInt32(quantity))
.Where(x => x.ITEM_POSITION == Convert.ToInt32(position))
.Execute();
How will I add an AND clause this is how it looks like in plain SQL:
UPDATE TB_ITEM
SET ITEM_DURABITLITY=@quantity
WHERE ...
I tried 3 variants but doesn't seem to update (I am using Linq Templates and MSSQL)
Luna.Data.GameDBDB db = new Luna.Data.GameDBDB();
db.Update<Luna.Record.TB_ITEM>()
.Set(x => x.ITEM_DURABILITY == Convert.ToInt32(quantity))
.Where(x => x.ITEM_DBIDX == Convert.ToInt32(dbdidx))
.Execute();
Here is the o...
Hi,
I have a table called "Users" that has a column called "deleted", a boolean indicating that the user is "Deleted" from the system (without actually deleting it, of course).
I also have a lot of tables that have a FK to the Users.user_id column. Subsonic generates (very nicely) the code for all the foreign keys in a similar manner:...
I can't seem to find an answer to this question or a good example of how to accomplish what I am trying to do. I'm sure it's been posted or explained somewhere, but I am having trouble finding the exact solution I need.
I am using ActiveRecord in Subsonic 3.0.0.4. When I do something like
recordset = VehicleModel.Find(x => x.Model.Sta...
I'm trying to figure out the correct way to atomically increment a counter in one table and use that incremented value as an pseudo display-only ID for a record in another.
What I have is a companies table and a jobs table. I want each company to have it's own set of job_numbers. I do have an auto increment job_id, but those numbers a...
Disclaimer: I jumped to C# 2008 recently and SubSonic 3 (3.0.0.4) at the same time. I haven't used Linq for much of anything in the past.
Is there an easy way to use the foreign key display value for sorting, rather than the FK Id (which is numeric)?
I've added a new Find method in my ActiveRecord.tt to help with sorting based on a st...
I'm sure I'm missing the obvious answer here, but could use a hand. I'm new to SubSonic and using version 3. I've got myself to the point of being able to query and insert, but I'm stuck with how I would get the value of the identity column back after my insert. I saw another post that mentioned Linq Templates. I'm not using those (a...
Hi everyone,
Here is code for the InnerJoin and I am using MSSQL 2005.
public static DataTable GetItemList()
{
DataTable dt = new DataTable();
IDataReader reader = _db.Select
.From<Item>()
.Where(ItemTable.IsDeletedColumn).IsEqualTo(false)
...
[We are using ActiveRecord.]
While running Sql Server Profiler, we noticed that a simple "Save" was preceded by a good bit of database activity. We found that the SubSonic core runs through all the properties and saves their values in a dictionary before it actually does the save.
We typically "extend" our data objects in partial class...
Hello, I am using SubSonic with the ActiveRecord template. I like it pretty well so far but can not figure out how to do a join query. I have read this link but the generated class templates it creates does not have anything of type IColumn
Is there something I am missing here? Also, I am using SubSonic 3.0
...
Has anyone had this issue? I am trying to get objects from the database and create a complex poco but I get a cast issue.
The Account property on the poco message type is a poco account type and it will tell me that whatever the first field type is can't be cast to PocoAccount, so in the example below, AccountID is an int so i'll get in...
What's the easiest way to exclude a column from the result set in a Subsonic/ActiveRecord/Linq query?
I've a got a table of images, and often I only want the meta data associated with the image (image id/name/dimensions for example). Seems fairly wasteful to be pulling in the entire image data for these requests.
My current thought is...