Пример #1
0
        public void CreateOrUpdate(MyRow request)
        {
            var connection = SqlConnections.NewFor <MyRow>();

            var q = new SqlQuery().Select("*").From(MyRow.Fields.TableName, new Alias("T0"))
                    .Where(new Criteria(MyRow.Fields.UserName) == request.UserName &
                           new Criteria(MyRow.Fields.SessionId) == request.SessionId);

            var result = connection.Query <MyRow>(q);

            if (result != null)
            {
                var list = result.ToList();
                if (list.Count > 0)
                {
                    Update(connection, request);
                    return;
                }
            }

            Create(connection, request);

            connection.Close();
        }