public AllDataTypes(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public Contact(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public MultiKey(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public TaskStatus(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public EightFields(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public PKDateTime(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public string GetListDataXml(string dataQuery) { StringBuilder sb = new StringBuilder(); XmlWriterSettings ws = new XmlWriterSettings(); ws.OmitXmlDeclaration = true; XmlWriter xw = XmlWriter.Create(sb, ws); xw.WriteStartElement("results"); using (SoodaTransaction st = new SoodaTransaction(typeof(Task).Assembly)) { TaskList tl = Task.GetList(TaskField.Status.In(TaskStatus.Assigned, TaskStatus.AssignedGroup, TaskStatus.Processing), SoodaSnapshotOptions.NoWriteObjects); foreach (Task tsk in tl) { xw.WriteStartElement("row"); xw.WriteElementString("Id", tsk.Id.ToString()); xw.WriteElementString("Title", tsk.Title); xw.WriteElementString("CreatedDate", tsk.CreatedDate.ToString()); xw.WriteElementString("CorrelationId", tsk.CorrelationId.ToString()); xw.WriteElementString("Assignee.Name", Convert.ToString(tsk.Evaluate("Assignee.Name"))); xw.WriteElementString("AssigneeGroup.Name", Convert.ToString(tsk.Evaluate("AssigneeGroup.Name"))); xw.WriteElementString("Status_Name", tsk.Status.Name); xw.WriteElementString("TaskId", tsk.TaskId.ToString()); xw.WriteEndElement(); } } xw.WriteEndElement(); xw.Flush(); return sb.ToString(); }
public ExtendedBike(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { // TODO - use Sooda here } }
public PKString(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
public MegaSuperBike(SoodaTransaction transaction) : base(transaction) { // // TODO: Add construction logic here. // }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { Category c = Category.Load(1); Console.WriteLine("The name of the category is {0}", c.Name); } }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { Product p = Product.Load(1); Console.WriteLine("Product: {0} category: {1} price: {2}", p.Name, p.Category.Name, p.UnitPrice); } }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { Category c = Category.Load(1); c.Name = "New Name"; transaction.Commit(); } }
protected void Page_Load(object sender, EventArgs e) { using (SoodaTransaction st = new SoodaTransaction(typeof(Task).Assembly)) { TaskList tl = Task.GetList(TaskField.Status.In(TaskStatus.Assigned, TaskStatus.AssignedGroup, TaskStatus.Processing), SoodaSnapshotOptions.NoWriteObjects); this.GridView1.DataSource = tl; this.GridView1.DataBind(); } }
public SoodaTransaction SetDefaultTransaction(SoodaTransaction transaction) { HttpContext currentContext = HttpContext.Current; if (currentContext == null) throw new Exception("Attempt to use transactions outside a HttpContext."); SoodaTransaction previousTransaction = GetDefaultTransaction(); currentContext.Items[_slot] = transaction; return previousTransaction; }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { Vehicle v; // load vehicle with #10 v = Vehicle.Load(10); if (v is Bike) { Console.WriteLine("vehicle #10 is a bike."); // do something with the bike Bike b = (Bike)v; } } }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { // load group with primary key 10 Group g = Group.Load(10); // display its manager's name Console.WriteLine("name: {0}", g.Manager.Name); // double the salary g.Manager.Salary *= 2; // save changes to the database transaction.Commit(); } }
static void Main() { using (SoodaTransaction transaction = new SoodaTransaction()) { // load group with primary key 10 Group g = Group.Load(10); // check if the manager is in role 'Customer' if (g.Manager.Roles.Contains(Role.Customer)) { // we have a manager that is a customer Console.WriteLine("{0} is both a manager and a customer!", g.Manager.Name); } // create a new contact that will become a member of Group[10] Contact newEmployee = new Contact(); // add necessary roles newEmployee.Roles.Add(Role.Customer); newEmployee.Roles.Add(Role.Employee); // set some required attributes newEmployee.Name = "Nancy Newcomer"; newEmployee.Type = ContactType.Employee; // add new employee as a member of the group g.Members.Add(newEmployee); // print some debugging information Console.WriteLine("Added {0} as a new member of {1}", newEmployee.Name, g.Name); // display group members - this includes Nancy Newcomer which // has just been added foreach (Contact c in g.Members) { Console.WriteLine("member name: {0}", c.Name); } // check if the administrator is a member of the group if (g.Members.Contains(Contact.Administrator)) { Console.WriteLine("Administrator is a member of {0}", g.Name); } // commit changes to the database transaction.Commit(); } }
public string SelectGroup(string root, string relations) { using (SoodaTransaction st = new SoodaTransaction(typeof(User).Assembly)) { object obj = SelectResource(root, relations); if (obj is Group) { return ((Group)obj).Id.ToString(); } else { string uid = Convert.ToString(obj); Group usr = FindGroupByGroupId(uid); if (usr == null) throw new ApplicationException("User not found for ID: " + uid); return usr.Id.ToString(); } } }
public static SoodaObject GetRefHelper(SoodaTransaction tran, ISoodaObjectFactory factory, Guid keyValue) { return GetRefHelper(tran, factory, (object)keyValue); }
private Task FindByCorrelationId(string instanceId, string correlationId, SoodaTransaction st) { TaskList tl = Task.GetList(st, TaskField.CorrelationId == correlationId); if (tl.Count > 0) return tl[0]; return null; }
protected override void OnPreInit(EventArgs e) { _transaction = new SoodaTransaction(ObjectsAssembly); }
public static SoodaObject GetRefFromRecordHelper(SoodaTransaction tran, ISoodaObjectFactory factory, IDataRecord record, int firstColumnIndex, TableInfo[] loadedTables, int tableIndex) { return GetRefFromRecordHelper(tran, factory, record, firstColumnIndex, loadedTables, tableIndex, true); }
internal static SoodaObject GetRefFromKeyRecordHelper(SoodaTransaction tran, ISoodaObjectFactory factory, IDataRecord record) { return GetRefFromRecordHelper(tran, factory, record, 0, null, -1, false); }
public Task(SoodaTransaction transaction) : base(transaction) { CreatedDate = DateTime.Now; }
public SoodaTransaction SetDefaultTransaction(SoodaTransaction transaction) { SoodaTransaction previousTransaction = GetDefaultTransaction(); Thread.SetData(_activeTransactionDataStoreSlot, transaction); return previousTransaction; }
protected SoodaObject(SoodaTransaction tran) { GC.SuppressFinalize(this); tran.Statistics.RegisterObjectInsert(); SoodaStatistics.Global.RegisterObjectInsert(); InitRawObject(tran); InsertMode = true; SetAllDataLoaded(); if (GetClassInfo().SubclassSelectorValue != null) { DisableFieldUpdateTriggers(); Sooda.Schema.FieldInfo selectorField = GetClassInfo().SubclassSelectorField; SetPlainFieldValue(0, selectorField.Name, selectorField.ClassUnifiedOrdinal, GetClassInfo().SubclassSelectorValue, null, null); EnableFieldUpdateTriggers(); } }
public void InitRawObject(SoodaTransaction tran) { _transaction = tran; _dataLoadedMask = 0; _flags = SoodaObjectFlags.InsertMode; _primaryKeyValue = null; }
public static SoodaObject GetRefHelper(SoodaTransaction tran, ISoodaObjectFactory factory, object keyValue) { SoodaObject retVal = factory.TryGet(tran, keyValue); if (retVal != null) return retVal; ClassInfo classInfo = factory.GetClassInfo(); if (classInfo.InheritsFromClass != null && tran.ExistsObjectWithKey(classInfo.GetRootClass().Name, keyValue)) throw new SoodaObjectNotFoundException(); if (classInfo.GetSubclassesForSchema(tran.Schema).Count > 0) { ISoodaObjectFactory newFactory = null; if (!classInfo.DisableTypeCache) { newFactory = SoodaTransaction.SoodaObjectFactoryCache.FindObjectFactory(classInfo.Name, keyValue); } if (newFactory != null) { factory = newFactory; } else { // if the class is actually inherited, we delegate the responsibility // to the appropriate GetRefFromRecord which will be called by the snapshot SoqlBooleanExpression where = null; Sooda.Schema.FieldInfo[] pkFields = classInfo.GetPrimaryKeyFields(); object[] par = new object[pkFields.Length]; for (int i = 0; i < pkFields.Length; ++i) { par[i] = SoodaTuple.GetValue(keyValue, i); SoqlBooleanExpression cmp = Soql.FieldEqualsParam(pkFields[i].Name, i); where = where == null ? cmp : where.And(cmp); } SoodaWhereClause whereClause = new SoodaWhereClause(where, par); IList list = factory.GetList(tran, whereClause, SoodaOrderBy.Unsorted, SoodaSnapshotOptions.NoTransaction | SoodaSnapshotOptions.NoWriteObjects | SoodaSnapshotOptions.NoCache); if (list.Count == 1) return (SoodaObject)list[0]; else if (list.Count == 0) throw new SoodaObjectNotFoundException("No matching object."); else throw new SoodaObjectNotFoundException("More than one object found. Fatal error."); } } retVal = factory.GetRawObject(tran); tran.Statistics.RegisterObjectUpdate(); SoodaStatistics.Global.RegisterObjectUpdate(); if (factory.GetClassInfo().ReadOnly) { retVal.LoadReadOnlyObject(keyValue); } else { retVal.SetUpdateMode(keyValue); } return retVal; }
internal RevertDisableKeyGenerators(SoodaTransaction trans, StringCollection classNames) { _trans = trans; _classNames = classNames; }