subsonic-active-record

Subsonic 3.0 UPDATE, multiple conditions

痴心易碎 提交于 2019-12-24 08:57:17
问题 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 ITEM_POSITION=@position AND CHARACTER_IDX=@charidx 回答1: .Where(x => x.ITEM_POSITION == Convert.ToInt32(position) && x.CHARACTER_IDX == Convert.ToInt32(charidx)) 来源: https://stackoverflow.com/questions/2623115

Subsonic 3.0 Medium Trust Issue

僤鯓⒐⒋嵵緔 提交于 2019-12-24 05:02:30
问题 I'm having an issue with running Subsonic in medium trust and don't know if i'm querying wrong - if there is some part of subsonic 3.0.3 that doesn't like medium trust can someone tell me? Someone else posted somethin similar a while ago and there was no real reply on whether it did exist or not (the bug). Rob said it had been tested, while someone else said they still had to bug (SubSonic 3.0 - Medium Trust) i'm using a query that looks like this: List<Data.Blog> objBlogPosts = ((from blog

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

SubSonic 3 and MySQL, removing underscore from column name in CleanUp() method causes exceptions when using property in linq-query

扶醉桌前 提交于 2019-12-19 11:58:18
问题 I've run into a problem when using SubSonic 3(.0.0.3) ActiveRecord with MySQL. Since MySQL doesn't allow you to use uppercase letters in table or column names (or rather disregards it if you do) I decided to separate words using underscores, e.g. entity_id, and then use the CleanUp() method to add title casing and remove the underscores. A friend wrote a ToTitleCase(string s) method that looks like this: string ToTitleCase(string s) { CultureInfo cultureInfo = Thread.CurrentThread

How can I automate the t4 code generation for SubSonic

北城以北 提交于 2019-12-12 19:14:36
问题 I'm using SubSonic 3 (ActiveRecord mode) to generate the code for my DAL. It uses T4 templates (.tt) files that as soon as you save, generate the code for you. I want to automate this as part of my NANT build, but I can't get this to work. I know that MS provide a tool called TextTransform to generate the code from T4 templates, but in the case of the SubSonic templates this doesn't seem to work - I think the templates make some assumptions about the template being run from within Visual

Fixes for problems with SubSonic 3's TestRepository

我的梦境 提交于 2019-12-11 00:41:25
问题 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 identity columns, this fix works well: (This is a copy from here, included for completeness) In ActiveRecord.tt: 1: In the top of the function public void Add

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

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

时光怂恿深爱的人放手 提交于 2019-12-04 11:02:05
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 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 action can be canceled from the partial methods. These two should be added too to the list of the existing ones

SubSonic 3 and MySQL, removing underscore from column name in CleanUp() method causes exceptions when using property in linq-query

血红的双手。 提交于 2019-12-01 14:39:11
I've run into a problem when using SubSonic 3(.0.0.3) ActiveRecord with MySQL. Since MySQL doesn't allow you to use uppercase letters in table or column names (or rather disregards it if you do) I decided to separate words using underscores, e.g. entity_id, and then use the CleanUp() method to add title casing and remove the underscores. A friend wrote a ToTitleCase(string s) method that looks like this: string ToTitleCase(string s) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; return textInfo.ToTitleCase(s); } And the CleanUp()