コード例 #1
0
        public IEnumerable <T> ExecuteDataTableByKey <T>(string id) where T : class, new()
        {
            T      t   = CreateSQLStr.CreateEntityByKey <T>(id);
            string sql = CreateSQLStr.SelectSQLStr <T>(t);

            return(ExecuteDataTable <T>(sql, CommandType.Text, null));
        }
コード例 #2
0
        public bool AddOrUpdate <T>(T entity) where T : class
        {
            if (typeof(T) == typeof(FlawInfoFeedBack))
            {
                try
                {
                    FlawInfoFeedBack record = entity as FlawInfoFeedBack;

                    Task.Run(() =>
                    {
                        lock (entity)
                        {
                            bool exist = ExecuteDataTableByKey <FlawInfoFeedBack>(record.ID).Count() > 0;
                            if (exist)
                            {
                                var sql = CreateSQLStr.UpdateSQLStr(entity);
                                return(ExecuteNonQuery(sql) > 0);
                            }
                            else
                            {
                                var sql = CreateSQLStr.SaveSQLStr(entity);
                                return(ExecuteNonQuery(sql) > 0);
                            }
                        }
                    });
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }

            throw new NotImplementedException();
        }